diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 552eeb53d..08da8b1f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Java id: setup-jre @@ -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 @@ -43,7 +43,7 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Java id: setup-jre diff --git a/build.gradle b/build.gradle index bf63dd2c4..66b7a8f44 100644 --- a/build.gradle +++ b/build.gradle @@ -44,7 +44,7 @@ java { group = 'dev.merge' -version = '1.1.1' +version = '2.0.0' jar { dependsOn(":generatePomFileForMavenPublication") @@ -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 { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index a4b76b953..1b33c55ba 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cea7a793a..ca025c83a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index f3b75f3b0..23d15a936 100755 --- a/gradlew +++ b/gradlew @@ -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. @@ -205,7 +205,7 @@ 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. @@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 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. diff --git a/gradlew.bat b/gradlew.bat index 9b42019c7..5eed7ee84 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -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 diff --git a/sample-app/src/main/java/sample/App.java b/sample-app/src/main/java/sample/App.java index 7102bf6ac..e443a5fd0 100644 --- a/sample-app/src/main/java/sample/App.java +++ b/sample-app/src/main/java/sample/App.java @@ -8,6 +8,6 @@ public final class App { public static void main(String[] args) { - // import com.merge.api.MergeApiClient + // import com.merge.api.AsyncMergeApiClient } } diff --git a/src/main/java/com/merge/api/AsyncMergeApiClient.java b/src/main/java/com/merge/api/AsyncMergeApiClient.java new file mode 100644 index 000000000..aeb966d38 --- /dev/null +++ b/src/main/java/com/merge/api/AsyncMergeApiClient.java @@ -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 atsClient; + + protected final Supplier accountingClient; + + protected final Supplier crmClient; + + protected final Supplier fileStorageClient; + + protected final Supplier hrisClient; + + protected final Supplier ticketingClient; + + public AsyncMergeApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.atsClient = Suppliers.memoize(() -> new AsyncAtsClient(clientOptions)); + this.accountingClient = Suppliers.memoize(() -> new AsyncAccountingClient(clientOptions)); + this.crmClient = Suppliers.memoize(() -> new AsyncCrmClient(clientOptions)); + this.fileStorageClient = Suppliers.memoize(() -> new AsyncFileStorageClient(clientOptions)); + this.hrisClient = Suppliers.memoize(() -> new AsyncHrisClient(clientOptions)); + this.ticketingClient = Suppliers.memoize(() -> new AsyncTicketingClient(clientOptions)); + } + + public AsyncAtsClient ats() { + return this.atsClient.get(); + } + + public AsyncAccountingClient accounting() { + return this.accountingClient.get(); + } + + public AsyncCrmClient crm() { + return this.crmClient.get(); + } + + public AsyncFileStorageClient fileStorage() { + return this.fileStorageClient.get(); + } + + public AsyncHrisClient hris() { + return this.hrisClient.get(); + } + + public AsyncTicketingClient ticketing() { + return this.ticketingClient.get(); + } + + public static AsyncMergeApiClientBuilder builder() { + return new AsyncMergeApiClientBuilder(); + } +} diff --git a/src/main/java/com/merge/api/AsyncMergeApiClientBuilder.java b/src/main/java/com/merge/api/AsyncMergeApiClientBuilder.java new file mode 100644 index 000000000..5d100f9a5 --- /dev/null +++ b/src/main/java/com/merge/api/AsyncMergeApiClientBuilder.java @@ -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()); + } +} diff --git a/src/main/java/com/merge/api/MergeApiClient.java b/src/main/java/com/merge/api/MergeApiClient.java index 61a58b09f..464294457 100644 --- a/src/main/java/com/merge/api/MergeApiClient.java +++ b/src/main/java/com/merge/api/MergeApiClient.java @@ -8,7 +8,7 @@ import com.merge.api.resources.accounting.AccountingClient; import com.merge.api.resources.ats.AtsClient; import com.merge.api.resources.crm.CrmClient; -import com.merge.api.resources.filestorage.FilestorageClient; +import com.merge.api.resources.filestorage.FileStorageClient; import com.merge.api.resources.hris.HrisClient; import com.merge.api.resources.ticketing.TicketingClient; import java.util.function.Supplier; @@ -18,48 +18,48 @@ public class MergeApiClient { protected final Supplier atsClient; - protected final Supplier crmClient; + protected final Supplier accountingClient; - protected final Supplier filestorageClient; + protected final Supplier crmClient; - protected final Supplier ticketingClient; + protected final Supplier fileStorageClient; protected final Supplier hrisClient; - protected final Supplier accountingClient; + protected final Supplier ticketingClient; public MergeApiClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.atsClient = Suppliers.memoize(() -> new AtsClient(clientOptions)); + this.accountingClient = Suppliers.memoize(() -> new AccountingClient(clientOptions)); this.crmClient = Suppliers.memoize(() -> new CrmClient(clientOptions)); - this.filestorageClient = Suppliers.memoize(() -> new FilestorageClient(clientOptions)); - this.ticketingClient = Suppliers.memoize(() -> new TicketingClient(clientOptions)); + this.fileStorageClient = Suppliers.memoize(() -> new FileStorageClient(clientOptions)); this.hrisClient = Suppliers.memoize(() -> new HrisClient(clientOptions)); - this.accountingClient = Suppliers.memoize(() -> new AccountingClient(clientOptions)); + this.ticketingClient = Suppliers.memoize(() -> new TicketingClient(clientOptions)); } public AtsClient ats() { return this.atsClient.get(); } - public CrmClient crm() { - return this.crmClient.get(); + public AccountingClient accounting() { + return this.accountingClient.get(); } - public FilestorageClient filestorage() { - return this.filestorageClient.get(); + public CrmClient crm() { + return this.crmClient.get(); } - public TicketingClient ticketing() { - return this.ticketingClient.get(); + public FileStorageClient fileStorage() { + return this.fileStorageClient.get(); } public HrisClient hris() { return this.hrisClient.get(); } - public AccountingClient accounting() { - return this.accountingClient.get(); + public TicketingClient ticketing() { + return this.ticketingClient.get(); } public static MergeApiClientBuilder builder() { diff --git a/src/main/java/com/merge/api/MergeApiClientBuilder.java b/src/main/java/com/merge/api/MergeApiClientBuilder.java index 7f8706b09..9e66bbfe6 100644 --- a/src/main/java/com/merge/api/MergeApiClientBuilder.java +++ b/src/main/java/com/merge/api/MergeApiClientBuilder.java @@ -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(); @@ -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"); diff --git a/src/main/java/com/merge/api/core/ApiError.java b/src/main/java/com/merge/api/core/ApiError.java index f3c2fd4a6..355ccf22a 100644 --- a/src/main/java/com/merge/api/core/ApiError.java +++ b/src/main/java/com/merge/api/core/ApiError.java @@ -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. */ @@ -17,10 +23,25 @@ public class ApiError extends MergeException { */ private final Object body; + private final Map> 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); + }); } /** @@ -37,6 +58,13 @@ public Object body() { return this.body; } + /** + * @return the headers + */ + public Map> headers() { + return this.headers; + } + @java.lang.Override public String toString() { return "ApiError{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body + "}"; diff --git a/src/main/java/com/merge/api/core/ClientOptions.java b/src/main/java/com/merge/api/core/ClientOptions.java index e200130e0..448cbf418 100644 --- a/src/main/java/com/merge/api/core/ClientOptions.java +++ b/src/main/java/com/merge/api/core/ClientOptions.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import okhttp3.OkHttpClient; @@ -31,9 +32,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { + put("User-Agent", "dev.merge:merge-java-client/2.0.0"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.merge.fern:api-sdk"); - put("X-Fern-SDK-Version", "1.1.1"); + put("X-Fern-SDK-Version", "2.0.0"); } }); this.headerSuppliers = headerSuppliers; @@ -56,6 +58,13 @@ public Map headers(RequestOptions requestOptions) { return values; } + public int timeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.timeout; + } + return requestOptions.getTimeout().orElse(this.timeout); + } + public OkHttpClient httpClient() { return this.httpClient; } @@ -84,7 +93,11 @@ public static final class Builder { private final Map> headerSuppliers = new HashMap<>(); - private int timeout = 60; + private int maxRetries = 2; + + private Optional timeout = Optional.empty(); + + private OkHttpClient httpClient = null; public Builder environment(Environment environment) { this.environment = environment; @@ -105,16 +118,54 @@ public Builder addHeader(String key, Supplier value) { * Override the timeout in seconds. Defaults to 60 seconds. */ public Builder timeout(int timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(Optional timeout) { this.timeout = timeout; return this; } + /** + * Override the maximum number of retries. Defaults to 2 retries. + */ + public Builder maxRetries(int maxRetries) { + this.maxRetries = maxRetries; + return this; + } + + public Builder httpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + public ClientOptions build() { - OkHttpClient okhttpClient = new OkHttpClient.Builder() - .addInterceptor(new RetryInterceptor(3)) - .callTimeout(this.timeout, TimeUnit.SECONDS) - .build(); - return new ClientOptions(environment, headers, headerSuppliers, okhttpClient, this.timeout); + OkHttpClient.Builder httpClientBuilder = + this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); + + if (this.httpClient != null) { + timeout.ifPresent(timeout -> httpClientBuilder + .callTimeout(timeout, TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS)); + } else { + httpClientBuilder + .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .addInterceptor(new RetryInterceptor(this.maxRetries)); + } + + this.httpClient = httpClientBuilder.build(); + this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); + + return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout.get()); } } } diff --git a/src/main/java/com/merge/api/core/Environment.java b/src/main/java/com/merge/api/core/Environment.java index 4c341119a..539d9bc52 100644 --- a/src/main/java/com/merge/api/core/Environment.java +++ b/src/main/java/com/merge/api/core/Environment.java @@ -4,11 +4,13 @@ package com.merge.api.core; public final class Environment { - public static final Environment PRODUCTION = new Environment("https://api.merge.dev/api"); + public static final Environment PRODUCTION = new Environment("https://api.merge.dev/api/ticketing/v1"); - public static final Environment SANDBOX = new Environment("https://api-sandbox.merge.dev/api"); + public static final Environment SANDBOX = new Environment("https://api-sandbox.merge.dev/api/ticketing/v1"); - public static final Environment PRODUCTION_EU = new Environment("https://api-eu.merge.dev/api"); + public static final Environment PRODUCTION_EU = new Environment("https://api-eu.merge.dev/api/ticketing/v1"); + + public static final Environment PRODUCTION_APSE_1 = new Environment("https://api-ap.merge.dev/api/ticketing/v1"); private final String url; diff --git a/src/main/java/com/merge/api/core/MergeApiHttpResponse.java b/src/main/java/com/merge/api/core/MergeApiHttpResponse.java new file mode 100644 index 000000000..bab13617e --- /dev/null +++ b/src/main/java/com/merge/api/core/MergeApiHttpResponse.java @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.Response; + +public final class MergeApiHttpResponse { + + private final T body; + + private final Map> headers; + + public MergeApiHttpResponse(T body, Response rawResponse) { + this.body = body; + + Map> headers = new HashMap<>(); + rawResponse.headers().forEach(header -> { + String key = header.component1(); + String value = header.component2(); + headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value); + }); + this.headers = headers; + } + + public T body() { + return this.body; + } + + public Map> headers() { + return headers; + } +} diff --git a/src/main/java/com/merge/api/core/Nullable.java b/src/main/java/com/merge/api/core/Nullable.java new file mode 100644 index 000000000..1a9724c30 --- /dev/null +++ b/src/main/java/com/merge/api/core/Nullable.java @@ -0,0 +1,140 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.core; + +import java.util.Optional; +import java.util.function.Function; + +public final class Nullable { + + private final Either, Null> value; + + private Nullable() { + this.value = Either.left(Optional.empty()); + } + + private Nullable(T value) { + if (value == null) { + this.value = Either.right(Null.INSTANCE); + } else { + this.value = Either.left(Optional.of(value)); + } + } + + public static Nullable ofNull() { + return new Nullable<>(null); + } + + public static Nullable of(T value) { + return new Nullable<>(value); + } + + public static Nullable empty() { + return new Nullable<>(); + } + + public static Nullable ofOptional(Optional value) { + if (value.isPresent()) { + return of(value.get()); + } else { + return empty(); + } + } + + public boolean isNull() { + return this.value.isRight(); + } + + public boolean isEmpty() { + return this.value.isLeft() && !this.value.getLeft().isPresent(); + } + + public T get() { + if (this.isNull()) { + return null; + } + + return this.value.getLeft().get(); + } + + public Nullable map(Function mapper) { + if (this.isNull()) { + return Nullable.ofNull(); + } + + return Nullable.ofOptional(this.value.getLeft().map(mapper)); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Nullable)) { + return false; + } + + if (((Nullable) other).isNull() && this.isNull()) { + return true; + } + + return this.value.getLeft().equals(((Nullable) other).value.getLeft()); + } + + private static final class Either { + private L left = null; + private R right = null; + + private Either(L left, R right) { + if (left != null && right != null) { + throw new IllegalArgumentException("Left and right argument cannot both be non-null."); + } + + if (left == null && right == null) { + throw new IllegalArgumentException("Left and right argument cannot both be null."); + } + + if (left != null) { + this.left = left; + } + + if (right != null) { + this.right = right; + } + } + + public static Either left(L left) { + return new Either<>(left, null); + } + + public static Either right(R right) { + return new Either<>(null, right); + } + + public boolean isLeft() { + return this.left != null; + } + + public boolean isRight() { + return this.right != null; + } + + public L getLeft() { + if (!this.isLeft()) { + throw new IllegalArgumentException("Cannot get left from right Either."); + } + return this.left; + } + + public R getRight() { + if (!this.isRight()) { + throw new IllegalArgumentException("Cannot get right from left Either."); + } + return this.right; + } + } + + private static final class Null { + private static final Null INSTANCE = new Null(); + + private Null() {} + } +} diff --git a/src/main/java/com/merge/api/core/NullableNonemptyFilter.java b/src/main/java/com/merge/api/core/NullableNonemptyFilter.java new file mode 100644 index 000000000..493a1abee --- /dev/null +++ b/src/main/java/com/merge/api/core/NullableNonemptyFilter.java @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.core; + +import java.util.Optional; + +public final class NullableNonemptyFilter { + @Override + public boolean equals(Object o) { + boolean isOptionalEmpty = isOptionalEmpty(o); + + return isOptionalEmpty; + } + + private boolean isOptionalEmpty(Object o) { + return o instanceof Optional && !((Optional) o).isPresent(); + } +} diff --git a/src/main/java/com/merge/api/core/QueryStringMapper.java b/src/main/java/com/merge/api/core/QueryStringMapper.java new file mode 100644 index 000000000..a2b9500f0 --- /dev/null +++ b/src/main/java/com/merge/api/core/QueryStringMapper.java @@ -0,0 +1,142 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.core; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import okhttp3.HttpUrl; +import okhttp3.MultipartBody; + +public class QueryStringMapper { + + private static final ObjectMapper MAPPER = ObjectMappers.JSON_MAPPER; + + public static void addQueryParameter(HttpUrl.Builder httpUrl, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + httpUrl.addQueryParameter(key, valueNode.textValue()); + } else { + httpUrl.addQueryParameter(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().textValue()); + } else { + httpUrl.addQueryParameter(key + field.getKey(), field.getValue().toString()); + } + } + } + + public static void addFormDataPart( + MultipartBody.Builder multipartBody, String key, Object value, boolean arraysAsRepeats) { + JsonNode valueNode = MAPPER.valueToTree(value); + + List> flat; + if (valueNode.isObject()) { + flat = flattenObject((ObjectNode) valueNode, arraysAsRepeats); + } else if (valueNode.isArray()) { + flat = flattenArray((ArrayNode) valueNode, "", arraysAsRepeats); + } else { + if (valueNode.isTextual()) { + multipartBody.addFormDataPart(key, valueNode.textValue()); + } else { + multipartBody.addFormDataPart(key, valueNode.toString()); + } + return; + } + + for (Map.Entry field : flat) { + if (field.getValue().isTextual()) { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().textValue()); + } else { + multipartBody.addFormDataPart( + key + field.getKey(), field.getValue().toString()); + } + } + } + + public static List> flattenObject(ObjectNode object, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator> fields = object.fields(); + while (fields.hasNext()) { + Map.Entry field = fields.next(); + + String key = "[" + field.getKey() + "]"; + + if (field.getValue().isObject()) { + List> flatField = + flattenObject((ObjectNode) field.getValue(), arraysAsRepeats); + addAll(flat, flatField, key); + } else if (field.getValue().isArray()) { + List> flatField = + flattenArray((ArrayNode) field.getValue(), key, arraysAsRepeats); + addAll(flat, flatField, ""); + } else { + flat.add(new AbstractMap.SimpleEntry<>(key, field.getValue())); + } + } + + return flat; + } + + private static List> flattenArray( + ArrayNode array, String key, boolean arraysAsRepeats) { + List> flat = new ArrayList<>(); + + Iterator elements = array.elements(); + + int index = 0; + while (elements.hasNext()) { + JsonNode element = elements.next(); + + String indexKey = key + "[" + index + "]"; + + if (arraysAsRepeats) { + indexKey = key; + } + + if (element.isObject()) { + List> flatField = flattenObject((ObjectNode) element, arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else if (element.isArray()) { + List> flatField = flattenArray((ArrayNode) element, "", arraysAsRepeats); + addAll(flat, flatField, indexKey); + } else { + flat.add(new AbstractMap.SimpleEntry<>(indexKey, element)); + } + + index++; + } + + return flat; + } + + private static void addAll( + List> target, List> source, String prefix) { + for (Map.Entry entry : source) { + Map.Entry entryToAdd = + new AbstractMap.SimpleEntry<>(prefix + entry.getKey(), entry.getValue()); + target.add(entryToAdd); + } + } +} diff --git a/src/main/java/com/merge/api/core/RequestOptions.java b/src/main/java/com/merge/api/core/RequestOptions.java index 69b3a07f7..d75805313 100644 --- a/src/main/java/com/merge/api/core/RequestOptions.java +++ b/src/main/java/com/merge/api/core/RequestOptions.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; public final class RequestOptions { private final String apiKey; @@ -17,11 +18,23 @@ public final class RequestOptions { private final TimeUnit timeoutTimeUnit; - private RequestOptions(String apiKey, String accountToken, Optional timeout, TimeUnit timeoutTimeUnit) { + private final Map headers; + + private final Map> headerSuppliers; + + private RequestOptions( + String apiKey, + String accountToken, + Optional timeout, + TimeUnit timeoutTimeUnit, + Map headers, + Map> headerSuppliers) { this.apiKey = apiKey; this.accountToken = accountToken; this.timeout = timeout; this.timeoutTimeUnit = timeoutTimeUnit; + this.headers = headers; + this.headerSuppliers = headerSuppliers; } public Optional getTimeout() { @@ -40,6 +53,10 @@ public Map getHeaders() { if (this.accountToken != null) { headers.put("X-Account-Token", this.accountToken); } + headers.putAll(this.headers); + this.headerSuppliers.forEach((key, supplier) -> { + headers.put(key, supplier.get()); + }); return headers; } @@ -56,6 +73,10 @@ public static final class Builder { private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + public Builder apiKey(String apiKey) { this.apiKey = apiKey; return this; @@ -77,8 +98,18 @@ public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { return this; } + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + public RequestOptions build() { - return new RequestOptions(apiKey, accountToken, timeout, timeoutTimeUnit); + return new RequestOptions(apiKey, accountToken, timeout, timeoutTimeUnit, headers, headerSuppliers); } } } diff --git a/src/main/java/com/merge/api/core/RetryInterceptor.java b/src/main/java/com/merge/api/core/RetryInterceptor.java index ce04332a5..fa040d5a2 100644 --- a/src/main/java/com/merge/api/core/RetryInterceptor.java +++ b/src/main/java/com/merge/api/core/RetryInterceptor.java @@ -52,7 +52,7 @@ private Response retryChain(Response response, Chain chain) throws IOException { } private static boolean shouldRetry(int statusCode) { - return statusCode == 408 || statusCode == 409 || statusCode == 429 || statusCode >= 500; + return statusCode == 408 || statusCode == 429 || statusCode >= 500; } private final class ExponentialBackoff { diff --git a/src/main/java/com/merge/api/core/Stream.java b/src/main/java/com/merge/api/core/Stream.java index d8c5e8661..40f7cc47b 100644 --- a/src/main/java/com/merge/api/core/Stream.java +++ b/src/main/java/com/merge/api/core/Stream.java @@ -9,7 +9,7 @@ import java.util.Scanner; /** - * The {@code Stream} class implmenets {@link Iterable} to provide a simple mechanism for reading and parsing + * The {@code Stream} class implements {@link Iterable} to provide a simple mechanism for reading and parsing * objects of a given type from data streamed via a {@link Reader} using a specified delimiter. *

* {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a @@ -23,7 +23,7 @@ public final class Stream implements Iterable { */ private final Class valueType; /** - * The {@link Scanner} used for reading from the input stream and blocking when neede during iteration. + * The {@link Scanner} used for reading from the input stream and blocking when needed during iteration. */ private final Scanner scanner; diff --git a/src/main/java/com/merge/api/resources/accounting/AccountingClient.java b/src/main/java/com/merge/api/resources/accounting/AccountingClient.java index a495f7358..a76f808f4 100644 --- a/src/main/java/com/merge/api/resources/accounting/AccountingClient.java +++ b/src/main/java/com/merge/api/resources/accounting/AccountingClient.java @@ -37,7 +37,9 @@ import com.merge.api.resources.accounting.linkedaccounts.LinkedAccountsClient; import com.merge.api.resources.accounting.linktoken.LinkTokenClient; import com.merge.api.resources.accounting.passthrough.PassthroughClient; +import com.merge.api.resources.accounting.paymentmethods.PaymentMethodsClient; import com.merge.api.resources.accounting.payments.PaymentsClient; +import com.merge.api.resources.accounting.paymentterms.PaymentTermsClient; import com.merge.api.resources.accounting.phonenumbers.PhoneNumbersClient; import com.merge.api.resources.accounting.purchaseorders.PurchaseOrdersClient; import com.merge.api.resources.accounting.regeneratekey.RegenerateKeyClient; @@ -117,6 +119,10 @@ public class AccountingClient { protected final Supplier passthroughClient; + protected final Supplier paymentMethodsClient; + + protected final Supplier paymentTermsClient; + protected final Supplier paymentsClient; protected final Supplier phoneNumbersClient; @@ -174,6 +180,8 @@ public AccountingClient(ClientOptions clientOptions) { this.linkTokenClient = Suppliers.memoize(() -> new LinkTokenClient(clientOptions)); this.linkedAccountsClient = Suppliers.memoize(() -> new LinkedAccountsClient(clientOptions)); this.passthroughClient = Suppliers.memoize(() -> new PassthroughClient(clientOptions)); + this.paymentMethodsClient = Suppliers.memoize(() -> new PaymentMethodsClient(clientOptions)); + this.paymentTermsClient = Suppliers.memoize(() -> new PaymentTermsClient(clientOptions)); this.paymentsClient = Suppliers.memoize(() -> new PaymentsClient(clientOptions)); this.phoneNumbersClient = Suppliers.memoize(() -> new PhoneNumbersClient(clientOptions)); this.purchaseOrdersClient = Suppliers.memoize(() -> new PurchaseOrdersClient(clientOptions)); @@ -315,6 +323,14 @@ public PassthroughClient passthrough() { return this.passthroughClient.get(); } + public PaymentMethodsClient paymentMethods() { + return this.paymentMethodsClient.get(); + } + + public PaymentTermsClient paymentTerms() { + return this.paymentTermsClient.get(); + } + public PaymentsClient payments() { return this.paymentsClient.get(); } diff --git a/src/main/java/com/merge/api/resources/accounting/AsyncAccountingClient.java b/src/main/java/com/merge/api/resources/accounting/AsyncAccountingClient.java new file mode 100644 index 000000000..e412e1e32 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/AsyncAccountingClient.java @@ -0,0 +1,377 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.Suppliers; +import com.merge.api.resources.accounting.accountdetails.AsyncAccountDetailsClient; +import com.merge.api.resources.accounting.accountingperiods.AsyncAccountingPeriodsClient; +import com.merge.api.resources.accounting.accounts.AsyncAccountsClient; +import com.merge.api.resources.accounting.accounttoken.AsyncAccountTokenClient; +import com.merge.api.resources.accounting.addresses.AsyncAddressesClient; +import com.merge.api.resources.accounting.asyncpassthrough.AsyncAsyncPassthroughClient; +import com.merge.api.resources.accounting.asynctasks.AsyncAsyncTasksClient; +import com.merge.api.resources.accounting.attachments.AsyncAttachmentsClient; +import com.merge.api.resources.accounting.audittrail.AsyncAuditTrailClient; +import com.merge.api.resources.accounting.availableactions.AsyncAvailableActionsClient; +import com.merge.api.resources.accounting.balancesheets.AsyncBalanceSheetsClient; +import com.merge.api.resources.accounting.bankfeedaccounts.AsyncBankFeedAccountsClient; +import com.merge.api.resources.accounting.bankfeedtransactions.AsyncBankFeedTransactionsClient; +import com.merge.api.resources.accounting.cashflowstatements.AsyncCashFlowStatementsClient; +import com.merge.api.resources.accounting.companyinfo.AsyncCompanyInfoClient; +import com.merge.api.resources.accounting.contacts.AsyncContactsClient; +import com.merge.api.resources.accounting.creditnotes.AsyncCreditNotesClient; +import com.merge.api.resources.accounting.deleteaccount.AsyncDeleteAccountClient; +import com.merge.api.resources.accounting.employees.AsyncEmployeesClient; +import com.merge.api.resources.accounting.expenses.AsyncExpensesClient; +import com.merge.api.resources.accounting.fieldmapping.AsyncFieldMappingClient; +import com.merge.api.resources.accounting.forceresync.AsyncForceResyncClient; +import com.merge.api.resources.accounting.generalledgertransactions.AsyncGeneralLedgerTransactionsClient; +import com.merge.api.resources.accounting.generatekey.AsyncGenerateKeyClient; +import com.merge.api.resources.accounting.incomestatements.AsyncIncomeStatementsClient; +import com.merge.api.resources.accounting.invoices.AsyncInvoicesClient; +import com.merge.api.resources.accounting.issues.AsyncIssuesClient; +import com.merge.api.resources.accounting.items.AsyncItemsClient; +import com.merge.api.resources.accounting.journalentries.AsyncJournalEntriesClient; +import com.merge.api.resources.accounting.linkedaccounts.AsyncLinkedAccountsClient; +import com.merge.api.resources.accounting.linktoken.AsyncLinkTokenClient; +import com.merge.api.resources.accounting.passthrough.AsyncPassthroughClient; +import com.merge.api.resources.accounting.paymentmethods.AsyncPaymentMethodsClient; +import com.merge.api.resources.accounting.payments.AsyncPaymentsClient; +import com.merge.api.resources.accounting.paymentterms.AsyncPaymentTermsClient; +import com.merge.api.resources.accounting.phonenumbers.AsyncPhoneNumbersClient; +import com.merge.api.resources.accounting.purchaseorders.AsyncPurchaseOrdersClient; +import com.merge.api.resources.accounting.regeneratekey.AsyncRegenerateKeyClient; +import com.merge.api.resources.accounting.scopes.AsyncScopesClient; +import com.merge.api.resources.accounting.syncstatus.AsyncSyncStatusClient; +import com.merge.api.resources.accounting.taxrates.AsyncTaxRatesClient; +import com.merge.api.resources.accounting.trackingcategories.AsyncTrackingCategoriesClient; +import com.merge.api.resources.accounting.transactions.AsyncTransactionsClient; +import com.merge.api.resources.accounting.vendorcredits.AsyncVendorCreditsClient; +import com.merge.api.resources.accounting.webhookreceivers.AsyncWebhookReceiversClient; +import java.util.function.Supplier; + +public class AsyncAccountingClient { + protected final ClientOptions clientOptions; + + protected final Supplier accountDetailsClient; + + protected final Supplier accountTokenClient; + + protected final Supplier accountingPeriodsClient; + + protected final Supplier accountsClient; + + protected final Supplier addressesClient; + + protected final Supplier asyncPassthroughClient; + + protected final Supplier asyncTasksClient; + + protected final Supplier attachmentsClient; + + protected final Supplier auditTrailClient; + + protected final Supplier availableActionsClient; + + protected final Supplier balanceSheetsClient; + + protected final Supplier bankFeedAccountsClient; + + protected final Supplier bankFeedTransactionsClient; + + protected final Supplier cashFlowStatementsClient; + + protected final Supplier companyInfoClient; + + protected final Supplier contactsClient; + + protected final Supplier creditNotesClient; + + protected final Supplier scopesClient; + + protected final Supplier deleteAccountClient; + + protected final Supplier employeesClient; + + protected final Supplier expensesClient; + + protected final Supplier fieldMappingClient; + + protected final Supplier generalLedgerTransactionsClient; + + protected final Supplier generateKeyClient; + + protected final Supplier incomeStatementsClient; + + protected final Supplier invoicesClient; + + protected final Supplier issuesClient; + + protected final Supplier itemsClient; + + protected final Supplier journalEntriesClient; + + protected final Supplier linkTokenClient; + + protected final Supplier linkedAccountsClient; + + protected final Supplier passthroughClient; + + protected final Supplier paymentMethodsClient; + + protected final Supplier paymentTermsClient; + + protected final Supplier paymentsClient; + + protected final Supplier phoneNumbersClient; + + protected final Supplier purchaseOrdersClient; + + protected final Supplier regenerateKeyClient; + + protected final Supplier syncStatusClient; + + protected final Supplier forceResyncClient; + + protected final Supplier taxRatesClient; + + protected final Supplier trackingCategoriesClient; + + protected final Supplier transactionsClient; + + protected final Supplier vendorCreditsClient; + + protected final Supplier webhookReceiversClient; + + public AsyncAccountingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.accountDetailsClient = Suppliers.memoize(() -> new AsyncAccountDetailsClient(clientOptions)); + this.accountTokenClient = Suppliers.memoize(() -> new AsyncAccountTokenClient(clientOptions)); + this.accountingPeriodsClient = Suppliers.memoize(() -> new AsyncAccountingPeriodsClient(clientOptions)); + this.accountsClient = Suppliers.memoize(() -> new AsyncAccountsClient(clientOptions)); + this.addressesClient = Suppliers.memoize(() -> new AsyncAddressesClient(clientOptions)); + this.asyncPassthroughClient = Suppliers.memoize(() -> new AsyncAsyncPassthroughClient(clientOptions)); + this.asyncTasksClient = Suppliers.memoize(() -> new AsyncAsyncTasksClient(clientOptions)); + this.attachmentsClient = Suppliers.memoize(() -> new AsyncAttachmentsClient(clientOptions)); + this.auditTrailClient = Suppliers.memoize(() -> new AsyncAuditTrailClient(clientOptions)); + this.availableActionsClient = Suppliers.memoize(() -> new AsyncAvailableActionsClient(clientOptions)); + this.balanceSheetsClient = Suppliers.memoize(() -> new AsyncBalanceSheetsClient(clientOptions)); + this.bankFeedAccountsClient = Suppliers.memoize(() -> new AsyncBankFeedAccountsClient(clientOptions)); + this.bankFeedTransactionsClient = Suppliers.memoize(() -> new AsyncBankFeedTransactionsClient(clientOptions)); + this.cashFlowStatementsClient = Suppliers.memoize(() -> new AsyncCashFlowStatementsClient(clientOptions)); + this.companyInfoClient = Suppliers.memoize(() -> new AsyncCompanyInfoClient(clientOptions)); + this.contactsClient = Suppliers.memoize(() -> new AsyncContactsClient(clientOptions)); + this.creditNotesClient = Suppliers.memoize(() -> new AsyncCreditNotesClient(clientOptions)); + this.scopesClient = Suppliers.memoize(() -> new AsyncScopesClient(clientOptions)); + this.deleteAccountClient = Suppliers.memoize(() -> new AsyncDeleteAccountClient(clientOptions)); + this.employeesClient = Suppliers.memoize(() -> new AsyncEmployeesClient(clientOptions)); + this.expensesClient = Suppliers.memoize(() -> new AsyncExpensesClient(clientOptions)); + this.fieldMappingClient = Suppliers.memoize(() -> new AsyncFieldMappingClient(clientOptions)); + this.generalLedgerTransactionsClient = + Suppliers.memoize(() -> new AsyncGeneralLedgerTransactionsClient(clientOptions)); + this.generateKeyClient = Suppliers.memoize(() -> new AsyncGenerateKeyClient(clientOptions)); + this.incomeStatementsClient = Suppliers.memoize(() -> new AsyncIncomeStatementsClient(clientOptions)); + this.invoicesClient = Suppliers.memoize(() -> new AsyncInvoicesClient(clientOptions)); + this.issuesClient = Suppliers.memoize(() -> new AsyncIssuesClient(clientOptions)); + this.itemsClient = Suppliers.memoize(() -> new AsyncItemsClient(clientOptions)); + this.journalEntriesClient = Suppliers.memoize(() -> new AsyncJournalEntriesClient(clientOptions)); + this.linkTokenClient = Suppliers.memoize(() -> new AsyncLinkTokenClient(clientOptions)); + this.linkedAccountsClient = Suppliers.memoize(() -> new AsyncLinkedAccountsClient(clientOptions)); + this.passthroughClient = Suppliers.memoize(() -> new AsyncPassthroughClient(clientOptions)); + this.paymentMethodsClient = Suppliers.memoize(() -> new AsyncPaymentMethodsClient(clientOptions)); + this.paymentTermsClient = Suppliers.memoize(() -> new AsyncPaymentTermsClient(clientOptions)); + this.paymentsClient = Suppliers.memoize(() -> new AsyncPaymentsClient(clientOptions)); + this.phoneNumbersClient = Suppliers.memoize(() -> new AsyncPhoneNumbersClient(clientOptions)); + this.purchaseOrdersClient = Suppliers.memoize(() -> new AsyncPurchaseOrdersClient(clientOptions)); + this.regenerateKeyClient = Suppliers.memoize(() -> new AsyncRegenerateKeyClient(clientOptions)); + this.syncStatusClient = Suppliers.memoize(() -> new AsyncSyncStatusClient(clientOptions)); + this.forceResyncClient = Suppliers.memoize(() -> new AsyncForceResyncClient(clientOptions)); + this.taxRatesClient = Suppliers.memoize(() -> new AsyncTaxRatesClient(clientOptions)); + this.trackingCategoriesClient = Suppliers.memoize(() -> new AsyncTrackingCategoriesClient(clientOptions)); + this.transactionsClient = Suppliers.memoize(() -> new AsyncTransactionsClient(clientOptions)); + this.vendorCreditsClient = Suppliers.memoize(() -> new AsyncVendorCreditsClient(clientOptions)); + this.webhookReceiversClient = Suppliers.memoize(() -> new AsyncWebhookReceiversClient(clientOptions)); + } + + public AsyncAccountDetailsClient accountDetails() { + return this.accountDetailsClient.get(); + } + + public AsyncAccountTokenClient accountToken() { + return this.accountTokenClient.get(); + } + + public AsyncAccountingPeriodsClient accountingPeriods() { + return this.accountingPeriodsClient.get(); + } + + public AsyncAccountsClient accounts() { + return this.accountsClient.get(); + } + + public AsyncAddressesClient addresses() { + return this.addressesClient.get(); + } + + public AsyncAsyncPassthroughClient asyncPassthrough() { + return this.asyncPassthroughClient.get(); + } + + public AsyncAsyncTasksClient asyncTasks() { + return this.asyncTasksClient.get(); + } + + public AsyncAttachmentsClient attachments() { + return this.attachmentsClient.get(); + } + + public AsyncAuditTrailClient auditTrail() { + return this.auditTrailClient.get(); + } + + public AsyncAvailableActionsClient availableActions() { + return this.availableActionsClient.get(); + } + + public AsyncBalanceSheetsClient balanceSheets() { + return this.balanceSheetsClient.get(); + } + + public AsyncBankFeedAccountsClient bankFeedAccounts() { + return this.bankFeedAccountsClient.get(); + } + + public AsyncBankFeedTransactionsClient bankFeedTransactions() { + return this.bankFeedTransactionsClient.get(); + } + + public AsyncCashFlowStatementsClient cashFlowStatements() { + return this.cashFlowStatementsClient.get(); + } + + public AsyncCompanyInfoClient companyInfo() { + return this.companyInfoClient.get(); + } + + public AsyncContactsClient contacts() { + return this.contactsClient.get(); + } + + public AsyncCreditNotesClient creditNotes() { + return this.creditNotesClient.get(); + } + + public AsyncScopesClient scopes() { + return this.scopesClient.get(); + } + + public AsyncDeleteAccountClient deleteAccount() { + return this.deleteAccountClient.get(); + } + + public AsyncEmployeesClient employees() { + return this.employeesClient.get(); + } + + public AsyncExpensesClient expenses() { + return this.expensesClient.get(); + } + + public AsyncFieldMappingClient fieldMapping() { + return this.fieldMappingClient.get(); + } + + public AsyncGeneralLedgerTransactionsClient generalLedgerTransactions() { + return this.generalLedgerTransactionsClient.get(); + } + + public AsyncGenerateKeyClient generateKey() { + return this.generateKeyClient.get(); + } + + public AsyncIncomeStatementsClient incomeStatements() { + return this.incomeStatementsClient.get(); + } + + public AsyncInvoicesClient invoices() { + return this.invoicesClient.get(); + } + + public AsyncIssuesClient issues() { + return this.issuesClient.get(); + } + + public AsyncItemsClient items() { + return this.itemsClient.get(); + } + + public AsyncJournalEntriesClient journalEntries() { + return this.journalEntriesClient.get(); + } + + public AsyncLinkTokenClient linkToken() { + return this.linkTokenClient.get(); + } + + public AsyncLinkedAccountsClient linkedAccounts() { + return this.linkedAccountsClient.get(); + } + + public AsyncPassthroughClient passthrough() { + return this.passthroughClient.get(); + } + + public AsyncPaymentMethodsClient paymentMethods() { + return this.paymentMethodsClient.get(); + } + + public AsyncPaymentTermsClient paymentTerms() { + return this.paymentTermsClient.get(); + } + + public AsyncPaymentsClient payments() { + return this.paymentsClient.get(); + } + + public AsyncPhoneNumbersClient phoneNumbers() { + return this.phoneNumbersClient.get(); + } + + public AsyncPurchaseOrdersClient purchaseOrders() { + return this.purchaseOrdersClient.get(); + } + + public AsyncRegenerateKeyClient regenerateKey() { + return this.regenerateKeyClient.get(); + } + + public AsyncSyncStatusClient syncStatus() { + return this.syncStatusClient.get(); + } + + public AsyncForceResyncClient forceResync() { + return this.forceResyncClient.get(); + } + + public AsyncTaxRatesClient taxRates() { + return this.taxRatesClient.get(); + } + + public AsyncTrackingCategoriesClient trackingCategories() { + return this.trackingCategoriesClient.get(); + } + + public AsyncTransactionsClient transactions() { + return this.transactionsClient.get(); + } + + public AsyncVendorCreditsClient vendorCredits() { + return this.vendorCreditsClient.get(); + } + + public AsyncWebhookReceiversClient webhookReceivers() { + return this.webhookReceiversClient.get(); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accountdetails/AccountDetailsClient.java b/src/main/java/com/merge/api/resources/accounting/accountdetails/AccountDetailsClient.java index f1de87003..555107868 100644 --- a/src/main/java/com/merge/api/resources/accounting/accountdetails/AccountDetailsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/accountdetails/AccountDetailsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.accounting.accountdetails; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.types.AccountDetails; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountDetailsClient { protected final ClientOptions clientOptions; + private final RawAccountDetailsClient rawClient; + public AccountDetailsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountDetailsClient withRawResponse() { + return this.rawClient; } /** * Get details for a linked account. */ public AccountDetails retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Get details for a linked account. */ public AccountDetails retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/account-details") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/accountdetails/AsyncAccountDetailsClient.java b/src/main/java/com/merge/api/resources/accounting/accountdetails/AsyncAccountDetailsClient.java new file mode 100644 index 000000000..8735f2520 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accountdetails/AsyncAccountDetailsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accountdetails; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AccountDetails; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountDetailsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountDetailsClient rawClient; + + public AsyncAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountDetailsClient withRawResponse() { + return this.rawClient; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accountdetails/AsyncRawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/accounting/accountdetails/AsyncRawAccountDetailsClient.java new file mode 100644 index 000000000..836befcde --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accountdetails/AsyncRawAccountDetailsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AccountDetails; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accountdetails/RawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/accounting/accountdetails/RawAccountDetailsClient.java new file mode 100644 index 000000000..10c1b888e --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accountdetails/RawAccountDetailsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AccountDetails; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public RawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accountingperiods/AccountingPeriodsClient.java b/src/main/java/com/merge/api/resources/accounting/accountingperiods/AccountingPeriodsClient.java index ba77866fc..7cb8e843a 100644 --- a/src/main/java/com/merge/api/resources/accounting/accountingperiods/AccountingPeriodsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/accountingperiods/AccountingPeriodsClient.java @@ -3,108 +3,63 @@ */ package com.merge.api.resources.accounting.accountingperiods; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.accountingperiods.requests.AccountingPeriodsListRequest; import com.merge.api.resources.accounting.accountingperiods.requests.AccountingPeriodsRetrieveRequest; import com.merge.api.resources.accounting.types.AccountingPeriod; import com.merge.api.resources.accounting.types.PaginatedAccountingPeriodList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountingPeriodsClient { protected final ClientOptions clientOptions; + private final RawAccountingPeriodsClient rawClient; + public AccountingPeriodsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountingPeriodsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountingPeriodsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of AccountingPeriod objects. */ public PaginatedAccountingPeriodList list() { - return list(AccountingPeriodsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of AccountingPeriod objects. */ public PaginatedAccountingPeriodList list(AccountingPeriodsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of AccountingPeriod objects. */ public PaginatedAccountingPeriodList list(AccountingPeriodsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/accounting-periods"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountingPeriodList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an AccountingPeriod object with the given id. */ public AccountingPeriod retrieve(String id) { - return retrieve(id, AccountingPeriodsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an AccountingPeriod object with the given id. */ public AccountingPeriod retrieve(String id, AccountingPeriodsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** @@ -112,37 +67,6 @@ public AccountingPeriod retrieve(String id, AccountingPeriodsRetrieveRequest req */ public AccountingPeriod retrieve( String id, AccountingPeriodsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/accounting-periods") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingPeriod.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/accountingperiods/AsyncAccountingPeriodsClient.java b/src/main/java/com/merge/api/resources/accounting/accountingperiods/AsyncAccountingPeriodsClient.java new file mode 100644 index 000000000..e83746da7 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accountingperiods/AsyncAccountingPeriodsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accountingperiods; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.accountingperiods.requests.AccountingPeriodsListRequest; +import com.merge.api.resources.accounting.accountingperiods.requests.AccountingPeriodsRetrieveRequest; +import com.merge.api.resources.accounting.types.AccountingPeriod; +import com.merge.api.resources.accounting.types.PaginatedAccountingPeriodList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountingPeriodsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountingPeriodsClient rawClient; + + public AsyncAccountingPeriodsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountingPeriodsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountingPeriodsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of AccountingPeriod objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of AccountingPeriod objects. + */ + public CompletableFuture list(AccountingPeriodsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of AccountingPeriod objects. + */ + public CompletableFuture list( + AccountingPeriodsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an AccountingPeriod object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an AccountingPeriod object with the given id. + */ + public CompletableFuture retrieve(String id, AccountingPeriodsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an AccountingPeriod object with the given id. + */ + public CompletableFuture retrieve( + String id, AccountingPeriodsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accountingperiods/AsyncRawAccountingPeriodsClient.java b/src/main/java/com/merge/api/resources/accounting/accountingperiods/AsyncRawAccountingPeriodsClient.java new file mode 100644 index 000000000..aad41302e --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accountingperiods/AsyncRawAccountingPeriodsClient.java @@ -0,0 +1,210 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accountingperiods; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.accountingperiods.requests.AccountingPeriodsListRequest; +import com.merge.api.resources.accounting.accountingperiods.requests.AccountingPeriodsRetrieveRequest; +import com.merge.api.resources.accounting.types.AccountingPeriod; +import com.merge.api.resources.accounting.types.PaginatedAccountingPeriodList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountingPeriodsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountingPeriodsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of AccountingPeriod objects. + */ + public CompletableFuture> list() { + return list(AccountingPeriodsListRequest.builder().build()); + } + + /** + * Returns a list of AccountingPeriod objects. + */ + public CompletableFuture> list( + AccountingPeriodsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of AccountingPeriod objects. + */ + public CompletableFuture> list( + AccountingPeriodsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounting-periods"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountingPeriodList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an AccountingPeriod object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, AccountingPeriodsRetrieveRequest.builder().build()); + } + + /** + * Returns an AccountingPeriod object with the given id. + */ + public CompletableFuture> retrieve( + String id, AccountingPeriodsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an AccountingPeriod object with the given id. + */ + public CompletableFuture> retrieve( + String id, AccountingPeriodsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounting-periods") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingPeriod.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accountingperiods/RawAccountingPeriodsClient.java b/src/main/java/com/merge/api/resources/accounting/accountingperiods/RawAccountingPeriodsClient.java new file mode 100644 index 000000000..7acef2e63 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accountingperiods/RawAccountingPeriodsClient.java @@ -0,0 +1,176 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accountingperiods; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.accountingperiods.requests.AccountingPeriodsListRequest; +import com.merge.api.resources.accounting.accountingperiods.requests.AccountingPeriodsRetrieveRequest; +import com.merge.api.resources.accounting.types.AccountingPeriod; +import com.merge.api.resources.accounting.types.PaginatedAccountingPeriodList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountingPeriodsClient { + protected final ClientOptions clientOptions; + + public RawAccountingPeriodsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of AccountingPeriod objects. + */ + public MergeApiHttpResponse list() { + return list(AccountingPeriodsListRequest.builder().build()); + } + + /** + * Returns a list of AccountingPeriod objects. + */ + public MergeApiHttpResponse list(AccountingPeriodsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of AccountingPeriod objects. + */ + public MergeApiHttpResponse list( + AccountingPeriodsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounting-periods"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountingPeriodList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an AccountingPeriod object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, AccountingPeriodsRetrieveRequest.builder().build()); + } + + /** + * Returns an AccountingPeriod object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, AccountingPeriodsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an AccountingPeriod object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, AccountingPeriodsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounting-periods") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingPeriod.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accountingperiods/requests/AccountingPeriodsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/accountingperiods/requests/AccountingPeriodsRetrieveRequest.java index 1382412e0..e18378721 100644 --- a/src/main/java/com/merge/api/resources/accounting/accountingperiods/requests/AccountingPeriodsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/accountingperiods/requests/AccountingPeriodsRetrieveRequest.java @@ -22,11 +22,16 @@ public final class AccountingPeriodsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private AccountingPeriodsRetrieveRequest( - Optional includeRemoteData, Map additionalProperties) { + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -38,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -50,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(AccountingPeriodsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -71,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -78,6 +93,7 @@ private Builder() {} public Builder from(AccountingPeriodsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -92,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public AccountingPeriodsRetrieveRequest build() { - return new AccountingPeriodsRetrieveRequest(includeRemoteData, additionalProperties); + return new AccountingPeriodsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/accounts/AccountsClient.java b/src/main/java/com/merge/api/resources/accounting/accounts/AccountsClient.java index 6c8d588de..3edad93d5 100644 --- a/src/main/java/com/merge/api/resources/accounting/accounts/AccountsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/accounts/AccountsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.accounts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.accounts.requests.AccountEndpointRequest; import com.merge.api.resources.accounting.accounts.requests.AccountsListRequest; @@ -16,283 +12,91 @@ import com.merge.api.resources.accounting.types.AccountResponse; import com.merge.api.resources.accounting.types.MetaResponse; import com.merge.api.resources.accounting.types.PaginatedAccountList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountsClient { protected final ClientOptions clientOptions; + private final RawAccountsClient rawClient; + public AccountsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Account objects. */ public PaginatedAccountList list() { - return list(AccountsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Account objects. */ public PaginatedAccountList list(AccountsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Account objects. */ public PaginatedAccountList list(AccountsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/accounts"); - if (request.getAccountType().isPresent()) { - httpUrl.addQueryParameter("account_type", request.getAccountType().get()); - } - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates an Account object with the given values. */ public AccountResponse create(AccountEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates an Account object with the given values. */ public AccountResponse create(AccountEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/accounts"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Account object with the given id. */ public Account retrieve(String id) { - return retrieve(id, AccountsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Account object with the given id. */ public Account retrieve(String id, AccountsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Account object with the given id. */ public Account retrieve(String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/accounts") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for Account POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Account POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/accounts/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/accounts/AsyncAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/accounts/AsyncAccountsClient.java new file mode 100644 index 000000000..ffda625ad --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accounts/AsyncAccountsClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accounts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.accounts.requests.AccountEndpointRequest; +import com.merge.api.resources.accounting.accounts.requests.AccountsListRequest; +import com.merge.api.resources.accounting.accounts.requests.AccountsRetrieveRequest; +import com.merge.api.resources.accounting.types.Account; +import com.merge.api.resources.accounting.types.AccountResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedAccountList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountsClient rawClient; + + public AsyncAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture list(AccountsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture list(AccountsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Account object with the given values. + */ + public CompletableFuture create(AccountEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Account object with the given values. + */ + public CompletableFuture create(AccountEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture retrieve(String id, AccountsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture retrieve( + String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Account POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Account POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accounts/AsyncRawAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/accounts/AsyncRawAccountsClient.java new file mode 100644 index 000000000..742de4223 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accounts/AsyncRawAccountsClient.java @@ -0,0 +1,413 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.accounts.requests.AccountEndpointRequest; +import com.merge.api.resources.accounting.accounts.requests.AccountsListRequest; +import com.merge.api.resources.accounting.accounts.requests.AccountsRetrieveRequest; +import com.merge.api.resources.accounting.types.Account; +import com.merge.api.resources.accounting.types.AccountResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedAccountList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture> list() { + return list(AccountsListRequest.builder().build()); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture> list(AccountsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture> list( + AccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounts"); + if (request.getAccountType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_type", request.getAccountType().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Account object with the given values. + */ + public CompletableFuture> create(AccountEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Account object with the given values. + */ + public CompletableFuture> create( + AccountEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, AccountsRetrieveRequest.builder().build()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture> retrieve(String id, AccountsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture> retrieve( + String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Account POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Account POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accounts/RawAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/accounts/RawAccountsClient.java new file mode 100644 index 000000000..b31afb703 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accounts/RawAccountsClient.java @@ -0,0 +1,353 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.accounts.requests.AccountEndpointRequest; +import com.merge.api.resources.accounting.accounts.requests.AccountsListRequest; +import com.merge.api.resources.accounting.accounts.requests.AccountsRetrieveRequest; +import com.merge.api.resources.accounting.types.Account; +import com.merge.api.resources.accounting.types.AccountResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedAccountList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountsClient { + protected final ClientOptions clientOptions; + + public RawAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Account objects. + */ + public MergeApiHttpResponse list() { + return list(AccountsListRequest.builder().build()); + } + + /** + * Returns a list of Account objects. + */ + public MergeApiHttpResponse list(AccountsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Account objects. + */ + public MergeApiHttpResponse list(AccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounts"); + if (request.getAccountType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_type", request.getAccountType().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Account object with the given values. + */ + public MergeApiHttpResponse create(AccountEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Account object with the given values. + */ + public MergeApiHttpResponse create(AccountEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Account object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, AccountsRetrieveRequest.builder().build()); + } + + /** + * Returns an Account object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, AccountsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Account object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Account POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Account POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/accounts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accounts/requests/AccountsListRequest.java b/src/main/java/com/merge/api/resources/accounting/accounts/requests/AccountsListRequest.java index 7baa57f85..8f53181c7 100644 --- a/src/main/java/com/merge/api/resources/accounting/accounts/requests/AccountsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/accounts/requests/AccountsListRequest.java @@ -15,7 +15,9 @@ import com.merge.api.resources.accounting.accounts.types.AccountsListRequestRemoteFields; import com.merge.api.resources.accounting.accounts.types.AccountsListRequestShowEnumOrigins; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,6 +25,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AccountsListRequest.Builder.class) public final class AccountsListRequest { + private final Optional> expand; + private final Optional accountType; private final Optional companyId; @@ -33,8 +37,6 @@ public final class AccountsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -45,6 +47,8 @@ public final class AccountsListRequest { private final Optional modifiedBefore; + private final Optional name; + private final Optional pageSize; private final Optional remoteFields; @@ -53,43 +57,57 @@ public final class AccountsListRequest { private final Optional showEnumOrigins; + private final Optional status; + private final Map additionalProperties; private AccountsListRequest( + Optional> expand, Optional accountType, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, Optional modifiedAfter, Optional modifiedBefore, + Optional name, Optional pageSize, Optional remoteFields, Optional remoteId, Optional showEnumOrigins, + Optional status, Map additionalProperties) { + this.expand = expand; this.accountType = accountType; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; this.modifiedAfter = modifiedAfter; this.modifiedBefore = modifiedBefore; + this.name = name; this.pageSize = pageSize; this.remoteFields = remoteFields; this.remoteId = remoteId; this.showEnumOrigins = showEnumOrigins; + this.status = status; this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only provide accounts with the passed in enum. */ @@ -130,14 +148,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -178,6 +188,14 @@ public Optional getModifiedBefore() { return modifiedBefore; } + /** + * @return If provided, will only return Accounts with this name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + /** * @return Number of results to return per page. */ @@ -210,6 +228,14 @@ public Optional getShowEnumOrigins() { return showEnumOrigins; } + /** + * @return If provided, will only return accounts with this status. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -222,41 +248,45 @@ public Map getAdditionalProperties() { } private boolean equalTo(AccountsListRequest other) { - return accountType.equals(other.accountType) + return expand.equals(other.expand) + && accountType.equals(other.accountType) && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) && modifiedAfter.equals(other.modifiedAfter) && modifiedBefore.equals(other.modifiedBefore) + && name.equals(other.name) && pageSize.equals(other.pageSize) && remoteFields.equals(other.remoteFields) && remoteId.equals(other.remoteId) - && showEnumOrigins.equals(other.showEnumOrigins); + && showEnumOrigins.equals(other.showEnumOrigins) + && status.equals(other.status); } @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.accountType, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, this.modifiedAfter, this.modifiedBefore, + this.name, this.pageSize, this.remoteFields, this.remoteId, - this.showEnumOrigins); + this.showEnumOrigins, + this.status); } @java.lang.Override @@ -270,6 +300,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional accountType = Optional.empty(); private Optional companyId = Optional.empty(); @@ -280,8 +312,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -292,6 +322,8 @@ public static final class Builder { private Optional modifiedBefore = Optional.empty(); + private Optional name = Optional.empty(); + private Optional pageSize = Optional.empty(); private Optional remoteFields = Optional.empty(); @@ -300,27 +332,47 @@ public static final class Builder { private Optional showEnumOrigins = Optional.empty(); + private Optional status = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} public Builder from(AccountsListRequest other) { + expand(other.getExpand()); accountType(other.getAccountType()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); modifiedAfter(other.getModifiedAfter()); modifiedBefore(other.getModifiedBefore()); + name(other.getName()); pageSize(other.getPageSize()); remoteFields(other.getRemoteFields()); remoteId(other.getRemoteId()); showEnumOrigins(other.getShowEnumOrigins()); + status(other.getStatus()); + return this; + } + + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); return this; } @@ -379,17 +431,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -445,6 +486,17 @@ public Builder modifiedBefore(OffsetDateTime modifiedBefore) { return this; } + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) public Builder pageSize(Optional pageSize) { this.pageSize = pageSize; @@ -489,23 +541,36 @@ public Builder showEnumOrigins(AccountsListRequestShowEnumOrigins showEnumOrigin return this; } + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(String status) { + this.status = Optional.ofNullable(status); + return this; + } + public AccountsListRequest build() { return new AccountsListRequest( + expand, accountType, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, modifiedAfter, modifiedBefore, + name, pageSize, remoteFields, remoteId, showEnumOrigins, + status, additionalProperties); } } diff --git a/src/main/java/com/merge/api/resources/accounting/accounts/requests/AccountsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/accounts/requests/AccountsRetrieveRequest.java index 1dc22b4cf..477b20da5 100644 --- a/src/main/java/com/merge/api/resources/accounting/accounts/requests/AccountsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/accounts/requests/AccountsRetrieveRequest.java @@ -14,7 +14,9 @@ import com.merge.api.core.ObjectMappers; import com.merge.api.resources.accounting.accounts.types.AccountsRetrieveRequestRemoteFields; import com.merge.api.resources.accounting.accounts.types.AccountsRetrieveRequestShowEnumOrigins; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,10 +24,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AccountsRetrieveRequest.Builder.class) public final class AccountsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -33,13 +37,15 @@ public final class AccountsRetrieveRequest { private final Map additionalProperties; private AccountsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -49,7 +55,7 @@ private AccountsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -61,6 +67,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -91,13 +105,15 @@ public Map getAdditionalProperties() { private boolean equalTo(AccountsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -111,10 +127,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -127,22 +145,28 @@ private Builder() {} public Builder from(AccountsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -154,6 +178,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -178,7 +213,7 @@ public Builder showEnumOrigins(AccountsRetrieveRequestShowEnumOrigins showEnumOr public AccountsRetrieveRequest build() { return new AccountsRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/accounttoken/AccountTokenClient.java b/src/main/java/com/merge/api/resources/accounting/accounttoken/AccountTokenClient.java index 5f3f236a0..546c0003c 100644 --- a/src/main/java/com/merge/api/resources/accounting/accounttoken/AccountTokenClient.java +++ b/src/main/java/com/merge/api/resources/accounting/accounttoken/AccountTokenClient.java @@ -3,66 +3,38 @@ */ package com.merge.api.resources.accounting.accounttoken; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.types.AccountToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountTokenClient { protected final ClientOptions clientOptions; + private final RawAccountTokenClient rawClient; + public AccountTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountTokenClient withRawResponse() { + return this.rawClient; } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken) { - return retrieve(publicToken, null); + return this.rawClient.retrieve(publicToken).body(); } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/account-token") - .addPathSegment(publicToken) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(publicToken, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/accounttoken/AsyncAccountTokenClient.java b/src/main/java/com/merge/api/resources/accounting/accounttoken/AsyncAccountTokenClient.java new file mode 100644 index 000000000..35dd46db6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accounttoken/AsyncAccountTokenClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accounttoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AccountToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountTokenClient rawClient; + + public AsyncAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken) { + return this.rawClient.retrieve(publicToken).thenApply(response -> response.body()); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken, RequestOptions requestOptions) { + return this.rawClient.retrieve(publicToken, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accounttoken/AsyncRawAccountTokenClient.java b/src/main/java/com/merge/api/resources/accounting/accounttoken/AsyncRawAccountTokenClient.java new file mode 100644 index 000000000..642a574e1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accounttoken/AsyncRawAccountTokenClient.java @@ -0,0 +1,90 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AccountToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve( + String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/accounttoken/RawAccountTokenClient.java b/src/main/java/com/merge/api/resources/accounting/accounttoken/RawAccountTokenClient.java new file mode 100644 index 000000000..c41535cf8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/accounttoken/RawAccountTokenClient.java @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AccountToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountTokenClient { + protected final ClientOptions clientOptions; + + public RawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/addresses/AddressesClient.java b/src/main/java/com/merge/api/resources/accounting/addresses/AddressesClient.java index d4d8e1d94..6f6b6226d 100644 --- a/src/main/java/com/merge/api/resources/accounting/addresses/AddressesClient.java +++ b/src/main/java/com/merge/api/resources/accounting/addresses/AddressesClient.java @@ -3,84 +3,46 @@ */ package com.merge.api.resources.accounting.addresses; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.addresses.requests.AddressesRetrieveRequest; import com.merge.api.resources.accounting.types.Address; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AddressesClient { protected final ClientOptions clientOptions; + private final RawAddressesClient rawClient; + public AddressesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAddressesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAddressesClient withRawResponse() { + return this.rawClient; } /** * Returns an Address object with the given id. */ public Address retrieve(String id) { - return retrieve(id, AddressesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Address object with the given id. */ public Address retrieve(String id, AddressesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Address object with the given id. */ public Address retrieve(String id, AddressesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/addresses") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Address.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/addresses/AsyncAddressesClient.java b/src/main/java/com/merge/api/resources/accounting/addresses/AsyncAddressesClient.java new file mode 100644 index 000000000..591463f27 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/addresses/AsyncAddressesClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.addresses; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.addresses.requests.AddressesRetrieveRequest; +import com.merge.api.resources.accounting.types.Address; +import java.util.concurrent.CompletableFuture; + +public class AsyncAddressesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAddressesClient rawClient; + + public AsyncAddressesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAddressesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAddressesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns an Address object with the given id. + */ + public CompletableFuture

retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Address object with the given id. + */ + public CompletableFuture
retrieve(String id, AddressesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Address object with the given id. + */ + public CompletableFuture
retrieve( + String id, AddressesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/addresses/AsyncRawAddressesClient.java b/src/main/java/com/merge/api/resources/accounting/addresses/AsyncRawAddressesClient.java new file mode 100644 index 000000000..568b5f817 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/addresses/AsyncRawAddressesClient.java @@ -0,0 +1,119 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.addresses; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.addresses.requests.AddressesRetrieveRequest; +import com.merge.api.resources.accounting.types.Address; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAddressesClient { + protected final ClientOptions clientOptions; + + public AsyncRawAddressesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns an Address object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, AddressesRetrieveRequest.builder().build()); + } + + /** + * Returns an Address object with the given id. + */ + public CompletableFuture> retrieve(String id, AddressesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Address object with the given id. + */ + public CompletableFuture> retrieve( + String id, AddressesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/addresses") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Address.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/addresses/RawAddressesClient.java b/src/main/java/com/merge/api/resources/accounting/addresses/RawAddressesClient.java new file mode 100644 index 000000000..1299d72ff --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/addresses/RawAddressesClient.java @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.addresses; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.addresses.requests.AddressesRetrieveRequest; +import com.merge.api.resources.accounting.types.Address; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAddressesClient { + protected final ClientOptions clientOptions; + + public RawAddressesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns an Address object with the given id. + */ + public MergeApiHttpResponse
retrieve(String id) { + return retrieve(id, AddressesRetrieveRequest.builder().build()); + } + + /** + * Returns an Address object with the given id. + */ + public MergeApiHttpResponse
retrieve(String id, AddressesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Address object with the given id. + */ + public MergeApiHttpResponse
retrieve( + String id, AddressesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/addresses") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Address.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/addresses/requests/AddressesRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/addresses/requests/AddressesRetrieveRequest.java index 42ed97a10..da38ca1c1 100644 --- a/src/main/java/com/merge/api/resources/accounting/addresses/requests/AddressesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/addresses/requests/AddressesRetrieveRequest.java @@ -22,6 +22,8 @@ public final class AddressesRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -30,10 +32,12 @@ public final class AddressesRetrieveRequest { private AddressesRetrieveRequest( Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -47,6 +51,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -76,13 +88,14 @@ public Map getAdditionalProperties() { private boolean equalTo(AddressesRetrieveRequest other) { return includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash(this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -98,6 +111,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -109,6 +124,7 @@ private Builder() {} public Builder from(AddressesRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; @@ -125,6 +141,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -148,7 +175,8 @@ public Builder showEnumOrigins(String showEnumOrigins) { } public AddressesRetrieveRequest build() { - return new AddressesRetrieveRequest(includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + return new AddressesRetrieveRequest( + includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncAsyncPassthroughClient.java new file mode 100644 index 000000000..5e5409726 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncAsyncPassthroughClient.java @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.asyncpassthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.accounting.types.AsyncPassthroughReciept; +import com.merge.api.resources.accounting.types.DataPassthroughRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAsyncPassthroughClient rawClient; + + public AsyncAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAsyncPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create( + DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve(String asyncPassthroughReceiptId) { + return this.rawClient.retrieve(asyncPassthroughReceiptId).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncPassthroughClient.java index 9b4c6d9dc..9f1e70290 100644 --- a/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncPassthroughClient.java +++ b/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncPassthroughClient.java @@ -3,119 +3,56 @@ */ package com.merge.api.resources.accounting.asyncpassthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; import com.merge.api.resources.accounting.types.AsyncPassthroughReciept; import com.merge.api.resources.accounting.types.DataPassthroughRequest; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AsyncPassthroughClient { protected final ClientOptions clientOptions; + private final RawAsyncPassthroughClient rawClient; + public AsyncPassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAsyncPassthroughClient withRawResponse() { + return this.rawClient; } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/async-passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId) { - return retrieve(asyncPassthroughReceiptId, null); + return this.rawClient.retrieve(asyncPassthroughReceiptId).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/async-passthrough") - .addPathSegment(asyncPassthroughReceiptId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), AsyncPassthroughRetrieveResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncRawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncRawAsyncPassthroughClient.java new file mode 100644 index 000000000..62de006fb --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncRawAsyncPassthroughClient.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.accounting.types.AsyncPassthroughReciept; +import com.merge.api.resources.accounting.types.DataPassthroughRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughReciept.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/RawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/RawAsyncPassthroughClient.java new file mode 100644 index 000000000..dd0172a6f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/RawAsyncPassthroughClient.java @@ -0,0 +1,131 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.accounting.types.AsyncPassthroughReciept; +import com.merge.api.resources.accounting.types.DataPassthroughRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public RawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve(String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java b/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java index bd9fbaa24..5021e164d 100644 --- a/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java +++ b/src/main/java/com/merge/api/resources/accounting/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java @@ -30,6 +30,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((RemoteResponse) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializerAsyncPostTask object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an AsyncPostTask object with the given id. + */ + public CompletableFuture retrieve(String id, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/asynctasks/AsyncRawAsyncTasksClient.java b/src/main/java/com/merge/api/resources/accounting/asynctasks/AsyncRawAsyncTasksClient.java new file mode 100644 index 000000000..36f318207 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/asynctasks/AsyncRawAsyncTasksClient.java @@ -0,0 +1,89 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.asynctasks; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AsyncPostTask; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAsyncTasksClient { + protected final ClientOptions clientOptions; + + public AsyncRawAsyncTasksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns an AsyncPostTask object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, null); + } + + /** + * Returns an AsyncPostTask object with the given id. + */ + public CompletableFuture> retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/async-tasks") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPostTask.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/asynctasks/AsyncTasksClient.java b/src/main/java/com/merge/api/resources/accounting/asynctasks/AsyncTasksClient.java index fa296fddd..5da8c9f9d 100644 --- a/src/main/java/com/merge/api/resources/accounting/asynctasks/AsyncTasksClient.java +++ b/src/main/java/com/merge/api/resources/accounting/asynctasks/AsyncTasksClient.java @@ -3,66 +3,38 @@ */ package com.merge.api.resources.accounting.asynctasks; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.types.AsyncPostTask; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AsyncTasksClient { protected final ClientOptions clientOptions; + private final RawAsyncTasksClient rawClient; + public AsyncTasksClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAsyncTasksClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAsyncTasksClient withRawResponse() { + return this.rawClient; } /** * Returns an AsyncPostTask object with the given id. */ public AsyncPostTask retrieve(String id) { - return retrieve(id, null); + return this.rawClient.retrieve(id).body(); } /** * Returns an AsyncPostTask object with the given id. */ public AsyncPostTask retrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/async-tasks") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPostTask.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/asynctasks/RawAsyncTasksClient.java b/src/main/java/com/merge/api/resources/accounting/asynctasks/RawAsyncTasksClient.java new file mode 100644 index 000000000..982ed95b8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/asynctasks/RawAsyncTasksClient.java @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.asynctasks; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AsyncPostTask; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAsyncTasksClient { + protected final ClientOptions clientOptions; + + public RawAsyncTasksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns an AsyncPostTask object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, null); + } + + /** + * Returns an AsyncPostTask object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/async-tasks") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPostTask.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/attachments/AsyncAttachmentsClient.java b/src/main/java/com/merge/api/resources/accounting/attachments/AsyncAttachmentsClient.java new file mode 100644 index 000000000..1beda33ac --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/attachments/AsyncAttachmentsClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.attachments; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.attachments.requests.AccountingAttachmentEndpointRequest; +import com.merge.api.resources.accounting.attachments.requests.AttachmentsListRequest; +import com.merge.api.resources.accounting.attachments.requests.AttachmentsRetrieveRequest; +import com.merge.api.resources.accounting.types.AccountingAttachment; +import com.merge.api.resources.accounting.types.AccountingAttachmentResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedAccountingAttachmentList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAttachmentsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAttachmentsClient rawClient; + + public AsyncAttachmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAttachmentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAttachmentsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of AccountingAttachment objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of AccountingAttachment objects. + */ + public CompletableFuture list(AttachmentsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of AccountingAttachment objects. + */ + public CompletableFuture list( + AttachmentsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an AccountingAttachment object with the given values. + */ + public CompletableFuture create(AccountingAttachmentEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an AccountingAttachment object with the given values. + */ + public CompletableFuture create( + AccountingAttachmentEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an AccountingAttachment object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an AccountingAttachment object with the given id. + */ + public CompletableFuture retrieve(String id, AttachmentsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an AccountingAttachment object with the given id. + */ + public CompletableFuture retrieve( + String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for AccountingAttachment POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for AccountingAttachment POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/attachments/AsyncRawAttachmentsClient.java b/src/main/java/com/merge/api/resources/accounting/attachments/AsyncRawAttachmentsClient.java new file mode 100644 index 000000000..fbca8371d --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/attachments/AsyncRawAttachmentsClient.java @@ -0,0 +1,377 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.attachments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.attachments.requests.AccountingAttachmentEndpointRequest; +import com.merge.api.resources.accounting.attachments.requests.AttachmentsListRequest; +import com.merge.api.resources.accounting.attachments.requests.AttachmentsRetrieveRequest; +import com.merge.api.resources.accounting.types.AccountingAttachment; +import com.merge.api.resources.accounting.types.AccountingAttachmentResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedAccountingAttachmentList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAttachmentsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAttachmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of AccountingAttachment objects. + */ + public CompletableFuture> list() { + return list(AttachmentsListRequest.builder().build()); + } + + /** + * Returns a list of AccountingAttachment objects. + */ + public CompletableFuture> list( + AttachmentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of AccountingAttachment objects. + */ + public CompletableFuture> list( + AttachmentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/attachments"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountingAttachmentList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an AccountingAttachment object with the given values. + */ + public CompletableFuture> create( + AccountingAttachmentEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an AccountingAttachment object with the given values. + */ + public CompletableFuture> create( + AccountingAttachmentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/attachments"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AccountingAttachmentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an AccountingAttachment object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, AttachmentsRetrieveRequest.builder().build()); + } + + /** + * Returns an AccountingAttachment object with the given id. + */ + public CompletableFuture> retrieve( + String id, AttachmentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an AccountingAttachment object with the given id. + */ + public CompletableFuture> retrieve( + String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/attachments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingAttachment.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for AccountingAttachment POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for AccountingAttachment POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/attachments/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/attachments/AttachmentsClient.java b/src/main/java/com/merge/api/resources/accounting/attachments/AttachmentsClient.java index 27cc065b7..b46781911 100644 --- a/src/main/java/com/merge/api/resources/accounting/attachments/AttachmentsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/attachments/AttachmentsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.attachments; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.attachments.requests.AccountingAttachmentEndpointRequest; import com.merge.api.resources.accounting.attachments.requests.AttachmentsListRequest; @@ -16,118 +12,50 @@ import com.merge.api.resources.accounting.types.AccountingAttachmentResponse; import com.merge.api.resources.accounting.types.MetaResponse; import com.merge.api.resources.accounting.types.PaginatedAccountingAttachmentList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AttachmentsClient { protected final ClientOptions clientOptions; + private final RawAttachmentsClient rawClient; + public AttachmentsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAttachmentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAttachmentsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of AccountingAttachment objects. */ public PaginatedAccountingAttachmentList list() { - return list(AttachmentsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of AccountingAttachment objects. */ public PaginatedAccountingAttachmentList list(AttachmentsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of AccountingAttachment objects. */ public PaginatedAccountingAttachmentList list(AttachmentsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/attachments"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedAccountingAttachmentList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates an AccountingAttachment object with the given values. */ public AccountingAttachmentResponse create(AccountingAttachmentEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** @@ -135,141 +63,41 @@ public AccountingAttachmentResponse create(AccountingAttachmentEndpointRequest r */ public AccountingAttachmentResponse create( AccountingAttachmentEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/attachments"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingAttachmentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an AccountingAttachment object with the given id. */ public AccountingAttachment retrieve(String id) { - return retrieve(id, AttachmentsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an AccountingAttachment object with the given id. */ public AccountingAttachment retrieve(String id, AttachmentsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an AccountingAttachment object with the given id. */ public AccountingAttachment retrieve(String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/attachments") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingAttachment.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for AccountingAttachment POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for AccountingAttachment POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/attachments/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/attachments/RawAttachmentsClient.java b/src/main/java/com/merge/api/resources/accounting/attachments/RawAttachmentsClient.java new file mode 100644 index 000000000..f0c9cc4ba --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/attachments/RawAttachmentsClient.java @@ -0,0 +1,316 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.attachments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.attachments.requests.AccountingAttachmentEndpointRequest; +import com.merge.api.resources.accounting.attachments.requests.AttachmentsListRequest; +import com.merge.api.resources.accounting.attachments.requests.AttachmentsRetrieveRequest; +import com.merge.api.resources.accounting.types.AccountingAttachment; +import com.merge.api.resources.accounting.types.AccountingAttachmentResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedAccountingAttachmentList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAttachmentsClient { + protected final ClientOptions clientOptions; + + public RawAttachmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of AccountingAttachment objects. + */ + public MergeApiHttpResponse list() { + return list(AttachmentsListRequest.builder().build()); + } + + /** + * Returns a list of AccountingAttachment objects. + */ + public MergeApiHttpResponse list(AttachmentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of AccountingAttachment objects. + */ + public MergeApiHttpResponse list( + AttachmentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/attachments"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountingAttachmentList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an AccountingAttachment object with the given values. + */ + public MergeApiHttpResponse create(AccountingAttachmentEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an AccountingAttachment object with the given values. + */ + public MergeApiHttpResponse create( + AccountingAttachmentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/attachments"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingAttachmentResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an AccountingAttachment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, AttachmentsRetrieveRequest.builder().build()); + } + + /** + * Returns an AccountingAttachment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, AttachmentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an AccountingAttachment object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/attachments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingAttachment.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for AccountingAttachment POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for AccountingAttachment POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/attachments/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/attachments/requests/AttachmentsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/attachments/requests/AttachmentsRetrieveRequest.java index 7107c630e..3397854ca 100644 --- a/src/main/java/com/merge/api/resources/accounting/attachments/requests/AttachmentsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/attachments/requests/AttachmentsRetrieveRequest.java @@ -22,10 +22,16 @@ public final class AttachmentsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private AttachmentsRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private AttachmentsRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(AttachmentsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(AttachmentsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public AttachmentsRetrieveRequest build() { - return new AttachmentsRetrieveRequest(includeRemoteData, additionalProperties); + return new AttachmentsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/audittrail/AsyncAuditTrailClient.java b/src/main/java/com/merge/api/resources/accounting/audittrail/AsyncAuditTrailClient.java new file mode 100644 index 000000000..9a50f65e6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/audittrail/AsyncAuditTrailClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.audittrail; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.accounting.types.PaginatedAuditLogEventList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAuditTrailClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAuditTrailClient rawClient; + + public AsyncAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAuditTrailClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAuditTrailClient withRawResponse() { + return this.rawClient; + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list(AuditTrailListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list( + AuditTrailListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/audittrail/AsyncRawAuditTrailClient.java b/src/main/java/com/merge/api/resources/accounting/audittrail/AsyncRawAuditTrailClient.java new file mode 100644 index 000000000..7ca1a939a --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/audittrail/AsyncRawAuditTrailClient.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.accounting.types.PaginatedAuditLogEventList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAuditTrailClient { + protected final ClientOptions clientOptions; + + public AsyncRawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAuditLogEventList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/audittrail/AuditTrailClient.java b/src/main/java/com/merge/api/resources/accounting/audittrail/AuditTrailClient.java index b065f15dd..adaf46077 100644 --- a/src/main/java/com/merge/api/resources/accounting/audittrail/AuditTrailClient.java +++ b/src/main/java/com/merge/api/resources/accounting/audittrail/AuditTrailClient.java @@ -3,90 +3,46 @@ */ package com.merge.api.resources.accounting.audittrail; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.audittrail.requests.AuditTrailListRequest; import com.merge.api.resources.accounting.types.PaginatedAuditLogEventList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AuditTrailClient { protected final ClientOptions clientOptions; + private final RawAuditTrailClient rawClient; + public AuditTrailClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAuditTrailClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAuditTrailClient withRawResponse() { + return this.rawClient; } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list() { - return list(AuditTrailListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/audit-trail"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEventType().isPresent()) { - httpUrl.addQueryParameter("event_type", request.getEventType().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getUserEmail().isPresent()) { - httpUrl.addQueryParameter("user_email", request.getUserEmail().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/audittrail/RawAuditTrailClient.java b/src/main/java/com/merge/api/resources/accounting/audittrail/RawAuditTrailClient.java new file mode 100644 index 000000000..c00eb860f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/audittrail/RawAuditTrailClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.accounting.types.PaginatedAuditLogEventList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAuditTrailClient { + protected final ClientOptions clientOptions; + + public RawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/audittrail/requests/AuditTrailListRequest.java b/src/main/java/com/merge/api/resources/accounting/audittrail/requests/AuditTrailListRequest.java index 6ffa702d6..55c81f03a 100644 --- a/src/main/java/com/merge/api/resources/accounting/audittrail/requests/AuditTrailListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/audittrail/requests/AuditTrailListRequest.java @@ -68,7 +68,7 @@ public Optional getEndDate() { } /** - * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED + * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED */ @JsonProperty("event_type") public Optional getEventType() { diff --git a/src/main/java/com/merge/api/resources/accounting/availableactions/AsyncAvailableActionsClient.java b/src/main/java/com/merge/api/resources/accounting/availableactions/AsyncAvailableActionsClient.java new file mode 100644 index 000000000..5f48767a1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/availableactions/AsyncAvailableActionsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.availableactions; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AvailableActions; +import java.util.concurrent.CompletableFuture; + +public class AsyncAvailableActionsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAvailableActionsClient rawClient; + + public AsyncAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAvailableActionsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/availableactions/AsyncRawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/accounting/availableactions/AsyncRawAvailableActionsClient.java new file mode 100644 index 000000000..8a6f133c4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/availableactions/AsyncRawAvailableActionsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AvailableActions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/availableactions/AvailableActionsClient.java b/src/main/java/com/merge/api/resources/accounting/availableactions/AvailableActionsClient.java index 4ee1175d0..dbc6f181d 100644 --- a/src/main/java/com/merge/api/resources/accounting/availableactions/AvailableActionsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/availableactions/AvailableActionsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.accounting.availableactions; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.types.AvailableActions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AvailableActionsClient { protected final ClientOptions clientOptions; + private final RawAvailableActionsClient rawClient; + public AvailableActionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAvailableActionsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/available-actions") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/availableactions/RawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/accounting/availableactions/RawAvailableActionsClient.java new file mode 100644 index 000000000..ec44ba340 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/availableactions/RawAvailableActionsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.AvailableActions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public RawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/balancesheets/AsyncBalanceSheetsClient.java b/src/main/java/com/merge/api/resources/accounting/balancesheets/AsyncBalanceSheetsClient.java new file mode 100644 index 000000000..d7755b3fc --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/balancesheets/AsyncBalanceSheetsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.balancesheets; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.balancesheets.requests.BalanceSheetsListRequest; +import com.merge.api.resources.accounting.balancesheets.requests.BalanceSheetsRetrieveRequest; +import com.merge.api.resources.accounting.types.BalanceSheet; +import com.merge.api.resources.accounting.types.PaginatedBalanceSheetList; +import java.util.concurrent.CompletableFuture; + +public class AsyncBalanceSheetsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawBalanceSheetsClient rawClient; + + public AsyncBalanceSheetsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawBalanceSheetsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawBalanceSheetsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of BalanceSheet objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of BalanceSheet objects. + */ + public CompletableFuture list(BalanceSheetsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of BalanceSheet objects. + */ + public CompletableFuture list( + BalanceSheetsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a BalanceSheet object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a BalanceSheet object with the given id. + */ + public CompletableFuture retrieve(String id, BalanceSheetsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a BalanceSheet object with the given id. + */ + public CompletableFuture retrieve( + String id, BalanceSheetsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/balancesheets/AsyncRawBalanceSheetsClient.java b/src/main/java/com/merge/api/resources/accounting/balancesheets/AsyncRawBalanceSheetsClient.java new file mode 100644 index 000000000..4b92a34b0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/balancesheets/AsyncRawBalanceSheetsClient.java @@ -0,0 +1,244 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.balancesheets; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.balancesheets.requests.BalanceSheetsListRequest; +import com.merge.api.resources.accounting.balancesheets.requests.BalanceSheetsRetrieveRequest; +import com.merge.api.resources.accounting.types.BalanceSheet; +import com.merge.api.resources.accounting.types.PaginatedBalanceSheetList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawBalanceSheetsClient { + protected final ClientOptions clientOptions; + + public AsyncRawBalanceSheetsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of BalanceSheet objects. + */ + public CompletableFuture> list() { + return list(BalanceSheetsListRequest.builder().build()); + } + + /** + * Returns a list of BalanceSheet objects. + */ + public CompletableFuture> list(BalanceSheetsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of BalanceSheet objects. + */ + public CompletableFuture> list( + BalanceSheetsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/balance-sheets"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedBalanceSheetList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a BalanceSheet object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, BalanceSheetsRetrieveRequest.builder().build()); + } + + /** + * Returns a BalanceSheet object with the given id. + */ + public CompletableFuture> retrieve( + String id, BalanceSheetsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a BalanceSheet object with the given id. + */ + public CompletableFuture> retrieve( + String id, BalanceSheetsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/balance-sheets") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BalanceSheet.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/balancesheets/BalanceSheetsClient.java b/src/main/java/com/merge/api/resources/accounting/balancesheets/BalanceSheetsClient.java index 24fd7121b..c24307dca 100644 --- a/src/main/java/com/merge/api/resources/accounting/balancesheets/BalanceSheetsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/balancesheets/BalanceSheetsClient.java @@ -3,173 +3,69 @@ */ package com.merge.api.resources.accounting.balancesheets; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.balancesheets.requests.BalanceSheetsListRequest; import com.merge.api.resources.accounting.balancesheets.requests.BalanceSheetsRetrieveRequest; import com.merge.api.resources.accounting.types.BalanceSheet; import com.merge.api.resources.accounting.types.PaginatedBalanceSheetList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class BalanceSheetsClient { protected final ClientOptions clientOptions; + private final RawBalanceSheetsClient rawClient; + public BalanceSheetsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawBalanceSheetsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawBalanceSheetsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of BalanceSheet objects. */ public PaginatedBalanceSheetList list() { - return list(BalanceSheetsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of BalanceSheet objects. */ public PaginatedBalanceSheetList list(BalanceSheetsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of BalanceSheet objects. */ public PaginatedBalanceSheetList list(BalanceSheetsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/balance-sheets"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedBalanceSheetList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a BalanceSheet object with the given id. */ public BalanceSheet retrieve(String id) { - return retrieve(id, BalanceSheetsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a BalanceSheet object with the given id. */ public BalanceSheet retrieve(String id, BalanceSheetsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a BalanceSheet object with the given id. */ public BalanceSheet retrieve(String id, BalanceSheetsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/balance-sheets") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BalanceSheet.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/balancesheets/RawBalanceSheetsClient.java b/src/main/java/com/merge/api/resources/accounting/balancesheets/RawBalanceSheetsClient.java new file mode 100644 index 000000000..eee1d949f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/balancesheets/RawBalanceSheetsClient.java @@ -0,0 +1,211 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.balancesheets; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.balancesheets.requests.BalanceSheetsListRequest; +import com.merge.api.resources.accounting.balancesheets.requests.BalanceSheetsRetrieveRequest; +import com.merge.api.resources.accounting.types.BalanceSheet; +import com.merge.api.resources.accounting.types.PaginatedBalanceSheetList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawBalanceSheetsClient { + protected final ClientOptions clientOptions; + + public RawBalanceSheetsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of BalanceSheet objects. + */ + public MergeApiHttpResponse list() { + return list(BalanceSheetsListRequest.builder().build()); + } + + /** + * Returns a list of BalanceSheet objects. + */ + public MergeApiHttpResponse list(BalanceSheetsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of BalanceSheet objects. + */ + public MergeApiHttpResponse list( + BalanceSheetsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/balance-sheets"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedBalanceSheetList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a BalanceSheet object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, BalanceSheetsRetrieveRequest.builder().build()); + } + + /** + * Returns a BalanceSheet object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, BalanceSheetsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a BalanceSheet object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, BalanceSheetsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/balance-sheets") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BalanceSheet.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/balancesheets/requests/BalanceSheetsListRequest.java b/src/main/java/com/merge/api/resources/accounting/balancesheets/requests/BalanceSheetsListRequest.java index dc0a835f3..c075a9502 100644 --- a/src/main/java/com/merge/api/resources/accounting/balancesheets/requests/BalanceSheetsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/balancesheets/requests/BalanceSheetsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BalanceSheetsListRequest.Builder.class) public final class BalanceSheetsListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -29,8 +33,6 @@ public final class BalanceSheetsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -48,11 +50,11 @@ public final class BalanceSheetsListRequest { private final Map additionalProperties; private BalanceSheetsListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -61,11 +63,11 @@ private BalanceSheetsListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -76,6 +78,14 @@ private BalanceSheetsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return balance sheets for this company. */ @@ -108,14 +118,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -184,11 +186,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(BalanceSheetsListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -201,11 +203,11 @@ private boolean equalTo(BalanceSheetsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -226,6 +228,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -234,8 +238,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -256,11 +258,11 @@ public static final class Builder { private Builder() {} public Builder from(BalanceSheetsListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -271,6 +273,22 @@ public Builder from(BalanceSheetsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -315,17 +333,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -405,11 +412,11 @@ public Builder remoteId(String remoteId) { public BalanceSheetsListRequest build() { return new BalanceSheetsListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/balancesheets/requests/BalanceSheetsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/balancesheets/requests/BalanceSheetsRetrieveRequest.java index a647d103b..6a96dc718 100644 --- a/src/main/java/com/merge/api/resources/accounting/balancesheets/requests/BalanceSheetsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/balancesheets/requests/BalanceSheetsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BalanceSheetsRetrieveRequest.Builder.class) public final class BalanceSheetsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private BalanceSheetsRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private BalanceSheetsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(BalanceSheetsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(BalanceSheetsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public BalanceSheetsRetrieveRequest build() { - return new BalanceSheetsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new BalanceSheetsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/AsyncBankFeedAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/AsyncBankFeedAccountsClient.java new file mode 100644 index 000000000..c5a5b44a2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/AsyncBankFeedAccountsClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.bankfeedaccounts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountEndpointRequest; +import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountsListRequest; +import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountsRetrieveRequest; +import com.merge.api.resources.accounting.types.BankFeedAccount; +import com.merge.api.resources.accounting.types.BankFeedAccountResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedBankFeedAccountList; +import java.util.concurrent.CompletableFuture; + +public class AsyncBankFeedAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawBankFeedAccountsClient rawClient; + + public AsyncBankFeedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawBankFeedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawBankFeedAccountsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of BankFeedAccount objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of BankFeedAccount objects. + */ + public CompletableFuture list(BankFeedAccountsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of BankFeedAccount objects. + */ + public CompletableFuture list( + BankFeedAccountsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a BankFeedAccount object with the given values. + */ + public CompletableFuture create(BankFeedAccountEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a BankFeedAccount object with the given values. + */ + public CompletableFuture create( + BankFeedAccountEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a BankFeedAccount object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a BankFeedAccount object with the given id. + */ + public CompletableFuture retrieve(String id, BankFeedAccountsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a BankFeedAccount object with the given id. + */ + public CompletableFuture retrieve( + String id, BankFeedAccountsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for BankFeedAccount POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for BankFeedAccount POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/AsyncRawBankFeedAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/AsyncRawBankFeedAccountsClient.java new file mode 100644 index 000000000..6a5c85568 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/AsyncRawBankFeedAccountsClient.java @@ -0,0 +1,350 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.bankfeedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountEndpointRequest; +import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountsListRequest; +import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountsRetrieveRequest; +import com.merge.api.resources.accounting.types.BankFeedAccount; +import com.merge.api.resources.accounting.types.BankFeedAccountResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedBankFeedAccountList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawBankFeedAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawBankFeedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of BankFeedAccount objects. + */ + public CompletableFuture> list() { + return list(BankFeedAccountsListRequest.builder().build()); + } + + /** + * Returns a list of BankFeedAccount objects. + */ + public CompletableFuture> list( + BankFeedAccountsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of BankFeedAccount objects. + */ + public CompletableFuture> list( + BankFeedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-accounts"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedBankFeedAccountList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a BankFeedAccount object with the given values. + */ + public CompletableFuture> create( + BankFeedAccountEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a BankFeedAccount object with the given values. + */ + public CompletableFuture> create( + BankFeedAccountEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-accounts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), BankFeedAccountResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a BankFeedAccount object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, BankFeedAccountsRetrieveRequest.builder().build()); + } + + /** + * Returns a BankFeedAccount object with the given id. + */ + public CompletableFuture> retrieve( + String id, BankFeedAccountsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a BankFeedAccount object with the given id. + */ + public CompletableFuture> retrieve( + String id, BankFeedAccountsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-accounts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankFeedAccount.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for BankFeedAccount POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for BankFeedAccount POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-accounts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/BankFeedAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/BankFeedAccountsClient.java index e7b5beacb..1931520d4 100644 --- a/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/BankFeedAccountsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/BankFeedAccountsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.bankfeedaccounts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountEndpointRequest; import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountsListRequest; @@ -16,236 +12,91 @@ import com.merge.api.resources.accounting.types.BankFeedAccountResponse; import com.merge.api.resources.accounting.types.MetaResponse; import com.merge.api.resources.accounting.types.PaginatedBankFeedAccountList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class BankFeedAccountsClient { protected final ClientOptions clientOptions; + private final RawBankFeedAccountsClient rawClient; + public BankFeedAccountsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawBankFeedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawBankFeedAccountsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of BankFeedAccount objects. */ public PaginatedBankFeedAccountList list() { - return list(BankFeedAccountsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of BankFeedAccount objects. */ public PaginatedBankFeedAccountList list(BankFeedAccountsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of BankFeedAccount objects. */ public PaginatedBankFeedAccountList list(BankFeedAccountsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/bank-feed-accounts"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedBankFeedAccountList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a BankFeedAccount object with the given values. */ public BankFeedAccountResponse create(BankFeedAccountEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a BankFeedAccount object with the given values. */ public BankFeedAccountResponse create(BankFeedAccountEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/bank-feed-accounts"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankFeedAccountResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a BankFeedAccount object with the given id. */ public BankFeedAccount retrieve(String id) { - return retrieve(id, BankFeedAccountsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a BankFeedAccount object with the given id. */ public BankFeedAccount retrieve(String id, BankFeedAccountsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a BankFeedAccount object with the given id. */ public BankFeedAccount retrieve(String id, BankFeedAccountsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/bank-feed-accounts") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankFeedAccount.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for BankFeedAccount POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for BankFeedAccount POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/bank-feed-accounts/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/RawBankFeedAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/RawBankFeedAccountsClient.java new file mode 100644 index 000000000..0063f8780 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/RawBankFeedAccountsClient.java @@ -0,0 +1,287 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.bankfeedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountEndpointRequest; +import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountsListRequest; +import com.merge.api.resources.accounting.bankfeedaccounts.requests.BankFeedAccountsRetrieveRequest; +import com.merge.api.resources.accounting.types.BankFeedAccount; +import com.merge.api.resources.accounting.types.BankFeedAccountResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedBankFeedAccountList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawBankFeedAccountsClient { + protected final ClientOptions clientOptions; + + public RawBankFeedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of BankFeedAccount objects. + */ + public MergeApiHttpResponse list() { + return list(BankFeedAccountsListRequest.builder().build()); + } + + /** + * Returns a list of BankFeedAccount objects. + */ + public MergeApiHttpResponse list(BankFeedAccountsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of BankFeedAccount objects. + */ + public MergeApiHttpResponse list( + BankFeedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-accounts"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedBankFeedAccountList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a BankFeedAccount object with the given values. + */ + public MergeApiHttpResponse create(BankFeedAccountEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a BankFeedAccount object with the given values. + */ + public MergeApiHttpResponse create( + BankFeedAccountEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-accounts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankFeedAccountResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a BankFeedAccount object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, BankFeedAccountsRetrieveRequest.builder().build()); + } + + /** + * Returns a BankFeedAccount object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, BankFeedAccountsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a BankFeedAccount object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, BankFeedAccountsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-accounts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankFeedAccount.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for BankFeedAccount POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for BankFeedAccount POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-accounts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/requests/BankFeedAccountsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/requests/BankFeedAccountsRetrieveRequest.java index bd7adc139..439b3c944 100644 --- a/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/requests/BankFeedAccountsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedaccounts/requests/BankFeedAccountsRetrieveRequest.java @@ -22,11 +22,16 @@ public final class BankFeedAccountsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private BankFeedAccountsRetrieveRequest( - Optional includeRemoteData, Map additionalProperties) { + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -38,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -50,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(BankFeedAccountsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -71,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -78,6 +93,7 @@ private Builder() {} public Builder from(BankFeedAccountsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -92,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public BankFeedAccountsRetrieveRequest build() { - return new BankFeedAccountsRetrieveRequest(includeRemoteData, additionalProperties); + return new BankFeedAccountsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/AsyncBankFeedTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/AsyncBankFeedTransactionsClient.java new file mode 100644 index 000000000..fd0660f58 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/AsyncBankFeedTransactionsClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.bankfeedtransactions; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionEndpointRequest; +import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionsListRequest; +import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionsRetrieveRequest; +import com.merge.api.resources.accounting.types.BankFeedTransaction; +import com.merge.api.resources.accounting.types.BankFeedTransactionResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedBankFeedTransactionList; +import java.util.concurrent.CompletableFuture; + +public class AsyncBankFeedTransactionsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawBankFeedTransactionsClient rawClient; + + public AsyncBankFeedTransactionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawBankFeedTransactionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawBankFeedTransactionsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of BankFeedTransaction objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of BankFeedTransaction objects. + */ + public CompletableFuture list(BankFeedTransactionsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of BankFeedTransaction objects. + */ + public CompletableFuture list( + BankFeedTransactionsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a BankFeedTransaction object with the given values. + */ + public CompletableFuture create(BankFeedTransactionEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a BankFeedTransaction object with the given values. + */ + public CompletableFuture create( + BankFeedTransactionEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a BankFeedTransaction object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a BankFeedTransaction object with the given id. + */ + public CompletableFuture retrieve(String id, BankFeedTransactionsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a BankFeedTransaction object with the given id. + */ + public CompletableFuture retrieve( + String id, BankFeedTransactionsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for BankFeedTransaction POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for BankFeedTransaction POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/AsyncRawBankFeedTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/AsyncRawBankFeedTransactionsClient.java new file mode 100644 index 000000000..5357333af --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/AsyncRawBankFeedTransactionsClient.java @@ -0,0 +1,385 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.bankfeedtransactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionEndpointRequest; +import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionsListRequest; +import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionsRetrieveRequest; +import com.merge.api.resources.accounting.types.BankFeedTransaction; +import com.merge.api.resources.accounting.types.BankFeedTransactionResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedBankFeedTransactionList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawBankFeedTransactionsClient { + protected final ClientOptions clientOptions; + + public AsyncRawBankFeedTransactionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of BankFeedTransaction objects. + */ + public CompletableFuture> list() { + return list(BankFeedTransactionsListRequest.builder().build()); + } + + /** + * Returns a list of BankFeedTransaction objects. + */ + public CompletableFuture> list( + BankFeedTransactionsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of BankFeedTransaction objects. + */ + public CompletableFuture> list( + BankFeedTransactionsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-transactions"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsProcessed().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_processed", request.getIsProcessed().get().toString(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedBankFeedTransactionList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a BankFeedTransaction object with the given values. + */ + public CompletableFuture> create( + BankFeedTransactionEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a BankFeedTransaction object with the given values. + */ + public CompletableFuture> create( + BankFeedTransactionEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-transactions"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), BankFeedTransactionResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a BankFeedTransaction object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, BankFeedTransactionsRetrieveRequest.builder().build()); + } + + /** + * Returns a BankFeedTransaction object with the given id. + */ + public CompletableFuture> retrieve( + String id, BankFeedTransactionsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a BankFeedTransaction object with the given id. + */ + public CompletableFuture> retrieve( + String id, BankFeedTransactionsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-transactions") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankFeedTransaction.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for BankFeedTransaction POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for BankFeedTransaction POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-transactions/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/BankFeedTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/BankFeedTransactionsClient.java index 90555e092..0778ac729 100644 --- a/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/BankFeedTransactionsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/BankFeedTransactionsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.bankfeedtransactions; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionEndpointRequest; import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionsListRequest; @@ -16,36 +12,36 @@ import com.merge.api.resources.accounting.types.BankFeedTransactionResponse; import com.merge.api.resources.accounting.types.MetaResponse; import com.merge.api.resources.accounting.types.PaginatedBankFeedTransactionList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class BankFeedTransactionsClient { protected final ClientOptions clientOptions; + private final RawBankFeedTransactionsClient rawClient; + public BankFeedTransactionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawBankFeedTransactionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawBankFeedTransactionsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of BankFeedTransaction objects. */ public PaginatedBankFeedTransactionList list() { - return list(BankFeedTransactionsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of BankFeedTransaction objects. */ public PaginatedBankFeedTransactionList list(BankFeedTransactionsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** @@ -53,86 +49,14 @@ public PaginatedBankFeedTransactionList list(BankFeedTransactionsListRequest req */ public PaginatedBankFeedTransactionList list( BankFeedTransactionsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/bank-feed-transactions"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsProcessed().isPresent()) { - httpUrl.addQueryParameter( - "is_processed", request.getIsProcessed().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedBankFeedTransactionList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a BankFeedTransaction object with the given values. */ public BankFeedTransactionResponse create(BankFeedTransactionEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** @@ -140,63 +64,21 @@ public BankFeedTransactionResponse create(BankFeedTransactionEndpointRequest req */ public BankFeedTransactionResponse create( BankFeedTransactionEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/bank-feed-transactions"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankFeedTransactionResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a BankFeedTransaction object with the given id. */ public BankFeedTransaction retrieve(String id) { - return retrieve(id, BankFeedTransactionsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a BankFeedTransaction object with the given id. */ public BankFeedTransaction retrieve(String id, BankFeedTransactionsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** @@ -204,81 +86,20 @@ public BankFeedTransaction retrieve(String id, BankFeedTransactionsRetrieveReque */ public BankFeedTransaction retrieve( String id, BankFeedTransactionsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/bank-feed-transactions") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankFeedTransaction.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for BankFeedTransaction POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for BankFeedTransaction POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/bank-feed-transactions/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/RawBankFeedTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/RawBankFeedTransactionsClient.java new file mode 100644 index 000000000..8f549aaaf --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/RawBankFeedTransactionsClient.java @@ -0,0 +1,324 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.bankfeedtransactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionEndpointRequest; +import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionsListRequest; +import com.merge.api.resources.accounting.bankfeedtransactions.requests.BankFeedTransactionsRetrieveRequest; +import com.merge.api.resources.accounting.types.BankFeedTransaction; +import com.merge.api.resources.accounting.types.BankFeedTransactionResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedBankFeedTransactionList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawBankFeedTransactionsClient { + protected final ClientOptions clientOptions; + + public RawBankFeedTransactionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of BankFeedTransaction objects. + */ + public MergeApiHttpResponse list() { + return list(BankFeedTransactionsListRequest.builder().build()); + } + + /** + * Returns a list of BankFeedTransaction objects. + */ + public MergeApiHttpResponse list(BankFeedTransactionsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of BankFeedTransaction objects. + */ + public MergeApiHttpResponse list( + BankFeedTransactionsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-transactions"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsProcessed().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_processed", request.getIsProcessed().get().toString(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedBankFeedTransactionList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a BankFeedTransaction object with the given values. + */ + public MergeApiHttpResponse create(BankFeedTransactionEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a BankFeedTransaction object with the given values. + */ + public MergeApiHttpResponse create( + BankFeedTransactionEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-transactions"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankFeedTransactionResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a BankFeedTransaction object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, BankFeedTransactionsRetrieveRequest.builder().build()); + } + + /** + * Returns a BankFeedTransaction object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, BankFeedTransactionsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a BankFeedTransaction object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, BankFeedTransactionsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-transactions") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankFeedTransaction.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for BankFeedTransaction POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for BankFeedTransaction POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/bank-feed-transactions/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/requests/BankFeedTransactionsListRequest.java b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/requests/BankFeedTransactionsListRequest.java index a65989d6c..0f681143a 100644 --- a/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/requests/BankFeedTransactionsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/requests/BankFeedTransactionsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,14 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BankFeedTransactionsListRequest.Builder.class) public final class BankFeedTransactionsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -48,10 +50,10 @@ public final class BankFeedTransactionsListRequest { private final Map additionalProperties; private BankFeedTransactionsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -61,10 +63,10 @@ private BankFeedTransactionsListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -76,6 +78,14 @@ private BankFeedTransactionsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -100,14 +110,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -184,10 +186,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(BankFeedTransactionsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -201,10 +203,10 @@ private boolean equalTo(BankFeedTransactionsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -226,14 +228,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -256,10 +258,10 @@ public static final class Builder { private Builder() {} public Builder from(BankFeedTransactionsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -271,6 +273,22 @@ public Builder from(BankFeedTransactionsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -304,17 +322,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -405,10 +412,10 @@ public Builder remoteId(String remoteId) { public BankFeedTransactionsListRequest build() { return new BankFeedTransactionsListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/requests/BankFeedTransactionsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/requests/BankFeedTransactionsRetrieveRequest.java index d1a9a94c7..b838f91f9 100644 --- a/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/requests/BankFeedTransactionsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/bankfeedtransactions/requests/BankFeedTransactionsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BankFeedTransactionsRetrieveRequest.Builder.class) public final class BankFeedTransactionsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private BankFeedTransactionsRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private BankFeedTransactionsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -62,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(BankFeedTransactionsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -81,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -93,20 +113,26 @@ private Builder() {} public Builder from(BankFeedTransactionsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -118,8 +144,20 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public BankFeedTransactionsRetrieveRequest build() { - return new BankFeedTransactionsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new BankFeedTransactionsRetrieveRequest( + expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/cashflowstatements/AsyncCashFlowStatementsClient.java b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/AsyncCashFlowStatementsClient.java new file mode 100644 index 000000000..16ff4ed7d --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/AsyncCashFlowStatementsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.cashflowstatements; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.cashflowstatements.requests.CashFlowStatementsListRequest; +import com.merge.api.resources.accounting.cashflowstatements.requests.CashFlowStatementsRetrieveRequest; +import com.merge.api.resources.accounting.types.CashFlowStatement; +import com.merge.api.resources.accounting.types.PaginatedCashFlowStatementList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCashFlowStatementsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCashFlowStatementsClient rawClient; + + public AsyncCashFlowStatementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCashFlowStatementsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCashFlowStatementsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of CashFlowStatement objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of CashFlowStatement objects. + */ + public CompletableFuture list(CashFlowStatementsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of CashFlowStatement objects. + */ + public CompletableFuture list( + CashFlowStatementsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a CashFlowStatement object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a CashFlowStatement object with the given id. + */ + public CompletableFuture retrieve(String id, CashFlowStatementsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a CashFlowStatement object with the given id. + */ + public CompletableFuture retrieve( + String id, CashFlowStatementsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/cashflowstatements/AsyncRawCashFlowStatementsClient.java b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/AsyncRawCashFlowStatementsClient.java new file mode 100644 index 000000000..0fe133056 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/AsyncRawCashFlowStatementsClient.java @@ -0,0 +1,245 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.cashflowstatements; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.cashflowstatements.requests.CashFlowStatementsListRequest; +import com.merge.api.resources.accounting.cashflowstatements.requests.CashFlowStatementsRetrieveRequest; +import com.merge.api.resources.accounting.types.CashFlowStatement; +import com.merge.api.resources.accounting.types.PaginatedCashFlowStatementList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCashFlowStatementsClient { + protected final ClientOptions clientOptions; + + public AsyncRawCashFlowStatementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of CashFlowStatement objects. + */ + public CompletableFuture> list() { + return list(CashFlowStatementsListRequest.builder().build()); + } + + /** + * Returns a list of CashFlowStatement objects. + */ + public CompletableFuture> list( + CashFlowStatementsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of CashFlowStatement objects. + */ + public CompletableFuture> list( + CashFlowStatementsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/cash-flow-statements"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedCashFlowStatementList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a CashFlowStatement object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, CashFlowStatementsRetrieveRequest.builder().build()); + } + + /** + * Returns a CashFlowStatement object with the given id. + */ + public CompletableFuture> retrieve( + String id, CashFlowStatementsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a CashFlowStatement object with the given id. + */ + public CompletableFuture> retrieve( + String id, CashFlowStatementsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/cash-flow-statements") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CashFlowStatement.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/cashflowstatements/CashFlowStatementsClient.java b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/CashFlowStatementsClient.java index 0c1a3fcf3..6c5b4c178 100644 --- a/src/main/java/com/merge/api/resources/accounting/cashflowstatements/CashFlowStatementsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/CashFlowStatementsClient.java @@ -3,133 +3,63 @@ */ package com.merge.api.resources.accounting.cashflowstatements; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.cashflowstatements.requests.CashFlowStatementsListRequest; import com.merge.api.resources.accounting.cashflowstatements.requests.CashFlowStatementsRetrieveRequest; import com.merge.api.resources.accounting.types.CashFlowStatement; import com.merge.api.resources.accounting.types.PaginatedCashFlowStatementList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class CashFlowStatementsClient { protected final ClientOptions clientOptions; + private final RawCashFlowStatementsClient rawClient; + public CashFlowStatementsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCashFlowStatementsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCashFlowStatementsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of CashFlowStatement objects. */ public PaginatedCashFlowStatementList list() { - return list(CashFlowStatementsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of CashFlowStatement objects. */ public PaginatedCashFlowStatementList list(CashFlowStatementsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of CashFlowStatement objects. */ public PaginatedCashFlowStatementList list(CashFlowStatementsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/cash-flow-statements"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCashFlowStatementList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a CashFlowStatement object with the given id. */ public CashFlowStatement retrieve(String id) { - return retrieve(id, CashFlowStatementsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a CashFlowStatement object with the given id. */ public CashFlowStatement retrieve(String id, CashFlowStatementsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** @@ -137,40 +67,6 @@ public CashFlowStatement retrieve(String id, CashFlowStatementsRetrieveRequest r */ public CashFlowStatement retrieve( String id, CashFlowStatementsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/cash-flow-statements") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CashFlowStatement.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/cashflowstatements/RawCashFlowStatementsClient.java b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/RawCashFlowStatementsClient.java new file mode 100644 index 000000000..a1937e803 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/RawCashFlowStatementsClient.java @@ -0,0 +1,212 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.cashflowstatements; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.cashflowstatements.requests.CashFlowStatementsListRequest; +import com.merge.api.resources.accounting.cashflowstatements.requests.CashFlowStatementsRetrieveRequest; +import com.merge.api.resources.accounting.types.CashFlowStatement; +import com.merge.api.resources.accounting.types.PaginatedCashFlowStatementList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCashFlowStatementsClient { + protected final ClientOptions clientOptions; + + public RawCashFlowStatementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of CashFlowStatement objects. + */ + public MergeApiHttpResponse list() { + return list(CashFlowStatementsListRequest.builder().build()); + } + + /** + * Returns a list of CashFlowStatement objects. + */ + public MergeApiHttpResponse list(CashFlowStatementsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of CashFlowStatement objects. + */ + public MergeApiHttpResponse list( + CashFlowStatementsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/cash-flow-statements"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedCashFlowStatementList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a CashFlowStatement object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, CashFlowStatementsRetrieveRequest.builder().build()); + } + + /** + * Returns a CashFlowStatement object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, CashFlowStatementsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a CashFlowStatement object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, CashFlowStatementsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/cash-flow-statements") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CashFlowStatement.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/cashflowstatements/requests/CashFlowStatementsListRequest.java b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/requests/CashFlowStatementsListRequest.java index 30d7b896b..f09170614 100644 --- a/src/main/java/com/merge/api/resources/accounting/cashflowstatements/requests/CashFlowStatementsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/requests/CashFlowStatementsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CashFlowStatementsListRequest.Builder.class) public final class CashFlowStatementsListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -29,8 +33,6 @@ public final class CashFlowStatementsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -48,11 +50,11 @@ public final class CashFlowStatementsListRequest { private final Map additionalProperties; private CashFlowStatementsListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -61,11 +63,11 @@ private CashFlowStatementsListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -76,6 +78,14 @@ private CashFlowStatementsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return cash flow statements for this company. */ @@ -108,14 +118,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -184,11 +186,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(CashFlowStatementsListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -201,11 +203,11 @@ private boolean equalTo(CashFlowStatementsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -226,6 +228,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -234,8 +238,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -256,11 +258,11 @@ public static final class Builder { private Builder() {} public Builder from(CashFlowStatementsListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -271,6 +273,22 @@ public Builder from(CashFlowStatementsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -315,17 +333,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -405,11 +412,11 @@ public Builder remoteId(String remoteId) { public CashFlowStatementsListRequest build() { return new CashFlowStatementsListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/cashflowstatements/requests/CashFlowStatementsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/requests/CashFlowStatementsRetrieveRequest.java index 29db7c7f2..d19fd7165 100644 --- a/src/main/java/com/merge/api/resources/accounting/cashflowstatements/requests/CashFlowStatementsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/cashflowstatements/requests/CashFlowStatementsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CashFlowStatementsRetrieveRequest.Builder.class) public final class CashFlowStatementsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private CashFlowStatementsRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private CashFlowStatementsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(CashFlowStatementsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(CashFlowStatementsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,20 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public CashFlowStatementsRetrieveRequest build() { - return new CashFlowStatementsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new CashFlowStatementsRetrieveRequest( + expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/companyinfo/AsyncCompanyInfoClient.java b/src/main/java/com/merge/api/resources/accounting/companyinfo/AsyncCompanyInfoClient.java new file mode 100644 index 000000000..0166048dc --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/companyinfo/AsyncCompanyInfoClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.companyinfo; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.companyinfo.requests.CompanyInfoListRequest; +import com.merge.api.resources.accounting.companyinfo.requests.CompanyInfoRetrieveRequest; +import com.merge.api.resources.accounting.types.CompanyInfo; +import com.merge.api.resources.accounting.types.PaginatedCompanyInfoList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCompanyInfoClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCompanyInfoClient rawClient; + + public AsyncCompanyInfoClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCompanyInfoClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCompanyInfoClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of CompanyInfo objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of CompanyInfo objects. + */ + public CompletableFuture list(CompanyInfoListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of CompanyInfo objects. + */ + public CompletableFuture list( + CompanyInfoListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a CompanyInfo object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a CompanyInfo object with the given id. + */ + public CompletableFuture retrieve(String id, CompanyInfoRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a CompanyInfo object with the given id. + */ + public CompletableFuture retrieve( + String id, CompanyInfoRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/companyinfo/AsyncRawCompanyInfoClient.java b/src/main/java/com/merge/api/resources/accounting/companyinfo/AsyncRawCompanyInfoClient.java new file mode 100644 index 000000000..8d2fc95f3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/companyinfo/AsyncRawCompanyInfoClient.java @@ -0,0 +1,240 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.companyinfo; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.companyinfo.requests.CompanyInfoListRequest; +import com.merge.api.resources.accounting.companyinfo.requests.CompanyInfoRetrieveRequest; +import com.merge.api.resources.accounting.types.CompanyInfo; +import com.merge.api.resources.accounting.types.PaginatedCompanyInfoList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCompanyInfoClient { + protected final ClientOptions clientOptions; + + public AsyncRawCompanyInfoClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of CompanyInfo objects. + */ + public CompletableFuture> list() { + return list(CompanyInfoListRequest.builder().build()); + } + + /** + * Returns a list of CompanyInfo objects. + */ + public CompletableFuture> list(CompanyInfoListRequest request) { + return list(request, null); + } + + /** + * Returns a list of CompanyInfo objects. + */ + public CompletableFuture> list( + CompanyInfoListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/company-info"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedCompanyInfoList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a CompanyInfo object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, CompanyInfoRetrieveRequest.builder().build()); + } + + /** + * Returns a CompanyInfo object with the given id. + */ + public CompletableFuture> retrieve( + String id, CompanyInfoRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a CompanyInfo object with the given id. + */ + public CompletableFuture> retrieve( + String id, CompanyInfoRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/company-info") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyInfo.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/companyinfo/CompanyInfoClient.java b/src/main/java/com/merge/api/resources/accounting/companyinfo/CompanyInfoClient.java index 8ce45c26b..40b1191a9 100644 --- a/src/main/java/com/merge/api/resources/accounting/companyinfo/CompanyInfoClient.java +++ b/src/main/java/com/merge/api/resources/accounting/companyinfo/CompanyInfoClient.java @@ -3,170 +3,69 @@ */ package com.merge.api.resources.accounting.companyinfo; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.companyinfo.requests.CompanyInfoListRequest; import com.merge.api.resources.accounting.companyinfo.requests.CompanyInfoRetrieveRequest; import com.merge.api.resources.accounting.types.CompanyInfo; import com.merge.api.resources.accounting.types.PaginatedCompanyInfoList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class CompanyInfoClient { protected final ClientOptions clientOptions; + private final RawCompanyInfoClient rawClient; + public CompanyInfoClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCompanyInfoClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCompanyInfoClient withRawResponse() { + return this.rawClient; } /** * Returns a list of CompanyInfo objects. */ public PaginatedCompanyInfoList list() { - return list(CompanyInfoListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of CompanyInfo objects. */ public PaginatedCompanyInfoList list(CompanyInfoListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of CompanyInfo objects. */ public PaginatedCompanyInfoList list(CompanyInfoListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/company-info"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCompanyInfoList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a CompanyInfo object with the given id. */ public CompanyInfo retrieve(String id) { - return retrieve(id, CompanyInfoRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a CompanyInfo object with the given id. */ public CompanyInfo retrieve(String id, CompanyInfoRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a CompanyInfo object with the given id. */ public CompanyInfo retrieve(String id, CompanyInfoRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/company-info") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyInfo.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/companyinfo/RawCompanyInfoClient.java b/src/main/java/com/merge/api/resources/accounting/companyinfo/RawCompanyInfoClient.java new file mode 100644 index 000000000..7d32876bd --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/companyinfo/RawCompanyInfoClient.java @@ -0,0 +1,207 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.companyinfo; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.companyinfo.requests.CompanyInfoListRequest; +import com.merge.api.resources.accounting.companyinfo.requests.CompanyInfoRetrieveRequest; +import com.merge.api.resources.accounting.types.CompanyInfo; +import com.merge.api.resources.accounting.types.PaginatedCompanyInfoList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCompanyInfoClient { + protected final ClientOptions clientOptions; + + public RawCompanyInfoClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of CompanyInfo objects. + */ + public MergeApiHttpResponse list() { + return list(CompanyInfoListRequest.builder().build()); + } + + /** + * Returns a list of CompanyInfo objects. + */ + public MergeApiHttpResponse list(CompanyInfoListRequest request) { + return list(request, null); + } + + /** + * Returns a list of CompanyInfo objects. + */ + public MergeApiHttpResponse list( + CompanyInfoListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/company-info"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCompanyInfoList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a CompanyInfo object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, CompanyInfoRetrieveRequest.builder().build()); + } + + /** + * Returns a CompanyInfo object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, CompanyInfoRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a CompanyInfo object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, CompanyInfoRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/company-info") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyInfo.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/companyinfo/requests/CompanyInfoListRequest.java b/src/main/java/com/merge/api/resources/accounting/companyinfo/requests/CompanyInfoListRequest.java index dded57e3a..1cae32378 100644 --- a/src/main/java/com/merge/api/resources/accounting/companyinfo/requests/CompanyInfoListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/companyinfo/requests/CompanyInfoListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.companyinfo.types.CompanyInfoListRequestExpand; +import com.merge.api.resources.accounting.companyinfo.types.CompanyInfoListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,14 +24,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CompanyInfoListRequest.Builder.class) public final class CompanyInfoListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -47,10 +49,10 @@ public final class CompanyInfoListRequest { private final Map additionalProperties; private CompanyInfoListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -59,10 +61,10 @@ private CompanyInfoListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -73,6 +75,14 @@ private CompanyInfoListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -97,14 +107,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -173,10 +175,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(CompanyInfoListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -189,10 +191,10 @@ private boolean equalTo(CompanyInfoListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -213,14 +215,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -241,10 +243,10 @@ public static final class Builder { private Builder() {} public Builder from(CompanyInfoListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -255,6 +257,22 @@ public Builder from(CompanyInfoListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(CompanyInfoListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -288,17 +306,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(CompanyInfoListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -378,10 +385,10 @@ public Builder remoteId(String remoteId) { public CompanyInfoListRequest build() { return new CompanyInfoListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/companyinfo/requests/CompanyInfoRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/companyinfo/requests/CompanyInfoRetrieveRequest.java index a43205b56..b9d8e6076 100644 --- a/src/main/java/com/merge/api/resources/accounting/companyinfo/requests/CompanyInfoRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/companyinfo/requests/CompanyInfoRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.companyinfo.types.CompanyInfoRetrieveRequestExpand; +import com.merge.api.resources.accounting.companyinfo.types.CompanyInfoRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CompanyInfoRetrieveRequest.Builder.class) public final class CompanyInfoRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private CompanyInfoRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private CompanyInfoRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(CompanyInfoRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -83,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,20 +113,26 @@ private Builder() {} public Builder from(CompanyInfoRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(CompanyInfoRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(CompanyInfoRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -120,8 +144,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public CompanyInfoRetrieveRequest build() { - return new CompanyInfoRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new CompanyInfoRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoListRequestExpand.java deleted file mode 100644 index 60b7bcd04..000000000 --- a/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.companyinfo.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CompanyInfoListRequestExpand { - ADDRESSES("addresses"), - - ADDRESSES_PHONE_NUMBERS("addresses,phone_numbers"), - - PHONE_NUMBERS("phone_numbers"); - - private final String value; - - CompanyInfoListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoListRequestExpandItem.java new file mode 100644 index 000000000..8692b76be --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.companyinfo.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CompanyInfoListRequestExpandItem { + ADDRESSES("addresses"), + + PHONE_NUMBERS("phone_numbers"); + + private final String value; + + CompanyInfoListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoRetrieveRequestExpand.java deleted file mode 100644 index 333976601..000000000 --- a/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoRetrieveRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.companyinfo.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CompanyInfoRetrieveRequestExpand { - ADDRESSES("addresses"), - - ADDRESSES_PHONE_NUMBERS("addresses,phone_numbers"), - - PHONE_NUMBERS("phone_numbers"); - - private final String value; - - CompanyInfoRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoRetrieveRequestExpandItem.java new file mode 100644 index 000000000..0a7e07fe1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/companyinfo/types/CompanyInfoRetrieveRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.companyinfo.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CompanyInfoRetrieveRequestExpandItem { + ADDRESSES("addresses"), + + PHONE_NUMBERS("phone_numbers"); + + private final String value; + + CompanyInfoRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/contacts/AsyncContactsClient.java b/src/main/java/com/merge/api/resources/accounting/contacts/AsyncContactsClient.java new file mode 100644 index 000000000..cede2a149 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/contacts/AsyncContactsClient.java @@ -0,0 +1,129 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.contacts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.contacts.requests.ContactEndpointRequest; +import com.merge.api.resources.accounting.contacts.requests.ContactsListRequest; +import com.merge.api.resources.accounting.contacts.requests.ContactsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.contacts.requests.ContactsRetrieveRequest; +import com.merge.api.resources.accounting.types.Contact; +import com.merge.api.resources.accounting.types.ContactResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedContactList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncContactsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawContactsClient rawClient; + + public AsyncContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawContactsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawContactsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture list(ContactsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture list(ContactsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture create(ContactEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture create(ContactEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture retrieve(String id, ContactsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture retrieve( + String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Contact POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Contact POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/contacts/AsyncRawContactsClient.java b/src/main/java/com/merge/api/resources/accounting/contacts/AsyncRawContactsClient.java new file mode 100644 index 000000000..b86dce200 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/contacts/AsyncRawContactsClient.java @@ -0,0 +1,534 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.contacts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.contacts.requests.ContactEndpointRequest; +import com.merge.api.resources.accounting.contacts.requests.ContactsListRequest; +import com.merge.api.resources.accounting.contacts.requests.ContactsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.contacts.requests.ContactsRetrieveRequest; +import com.merge.api.resources.accounting.types.Contact; +import com.merge.api.resources.accounting.types.ContactResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedContactList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawContactsClient { + protected final ClientOptions clientOptions; + + public AsyncRawContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture> list() { + return list(ContactsListRequest.builder().build()); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture> list(ContactsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture> list( + ContactsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/contacts"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email_address", request.getEmailAddress().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCustomer().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_customer", request.getIsCustomer().get(), false); + } + if (request.getIsSupplier().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_supplier", request.getIsSupplier().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedContactList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture> create(ContactEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture> create( + ContactEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/contacts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, ContactsRetrieveRequest.builder().build()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture> retrieve(String id, ContactsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture> retrieve( + String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/contacts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Contact POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Contact POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/contacts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/contacts/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/contacts/ContactsClient.java b/src/main/java/com/merge/api/resources/accounting/contacts/ContactsClient.java index cc01207b5..543b5a817 100644 --- a/src/main/java/com/merge/api/resources/accounting/contacts/ContactsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/contacts/ContactsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.contacts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.contacts.requests.ContactEndpointRequest; import com.merge.api.resources.accounting.contacts.requests.ContactsListRequest; @@ -18,316 +14,106 @@ import com.merge.api.resources.accounting.types.MetaResponse; import com.merge.api.resources.accounting.types.PaginatedContactList; import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ContactsClient { protected final ClientOptions clientOptions; + private final RawContactsClient rawClient; + public ContactsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawContactsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawContactsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Contact objects. */ public PaginatedContactList list() { - return list(ContactsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Contact objects. */ public PaginatedContactList list(ContactsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Contact objects. */ public PaginatedContactList list(ContactsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/contacts"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmailAddress().isPresent()) { - httpUrl.addQueryParameter("email_address", request.getEmailAddress().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCustomer().isPresent()) { - httpUrl.addQueryParameter("is_customer", request.getIsCustomer().get()); - } - if (request.getIsSupplier().isPresent()) { - httpUrl.addQueryParameter("is_supplier", request.getIsSupplier().get()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedContactList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Contact object with the given values. */ public ContactResponse create(ContactEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Contact object with the given values. */ public ContactResponse create(ContactEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/contacts"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Contact object with the given id. */ public Contact retrieve(String id) { - return retrieve(id, ContactsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Contact object with the given id. */ public Contact retrieve(String id, ContactsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Contact object with the given id. */ public Contact retrieve(String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/contacts") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for Contact POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Contact POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/contacts/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - ContactsRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(ContactsRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -335,56 +121,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(ContactsRemoteFieldC */ public PaginatedRemoteFieldClassList remoteFieldClassesList( ContactsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/contacts/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/contacts/RawContactsClient.java b/src/main/java/com/merge/api/resources/accounting/contacts/RawContactsClient.java new file mode 100644 index 000000000..787e9d9b2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/contacts/RawContactsClient.java @@ -0,0 +1,460 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.contacts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.contacts.requests.ContactEndpointRequest; +import com.merge.api.resources.accounting.contacts.requests.ContactsListRequest; +import com.merge.api.resources.accounting.contacts.requests.ContactsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.contacts.requests.ContactsRetrieveRequest; +import com.merge.api.resources.accounting.types.Contact; +import com.merge.api.resources.accounting.types.ContactResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedContactList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawContactsClient { + protected final ClientOptions clientOptions; + + public RawContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Contact objects. + */ + public MergeApiHttpResponse list() { + return list(ContactsListRequest.builder().build()); + } + + /** + * Returns a list of Contact objects. + */ + public MergeApiHttpResponse list(ContactsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Contact objects. + */ + public MergeApiHttpResponse list(ContactsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/contacts"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email_address", request.getEmailAddress().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCustomer().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_customer", request.getIsCustomer().get(), false); + } + if (request.getIsSupplier().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_supplier", request.getIsSupplier().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedContactList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Contact object with the given values. + */ + public MergeApiHttpResponse create(ContactEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Contact object with the given values. + */ + public MergeApiHttpResponse create(ContactEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/contacts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ContactResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Contact object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, ContactsRetrieveRequest.builder().build()); + } + + /** + * Returns a Contact object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, ContactsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Contact object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/contacts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Contact POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Contact POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/contacts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/contacts/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/contacts/requests/ContactsListRequest.java b/src/main/java/com/merge/api/resources/accounting/contacts/requests/ContactsListRequest.java index 67b527bf6..c0212b588 100644 --- a/src/main/java/com/merge/api/resources/accounting/contacts/requests/ContactsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/contacts/requests/ContactsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.contacts.types.ContactsListRequestExpand; +import com.merge.api.resources.accounting.contacts.types.ContactsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContactsListRequest.Builder.class) public final class ContactsListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -32,8 +36,6 @@ public final class ContactsListRequest { private final Optional emailAddress; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -60,15 +62,17 @@ public final class ContactsListRequest { private final Optional showEnumOrigins; + private final Optional status; + private final Map additionalProperties; private ContactsListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, Optional emailAddress, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -82,13 +86,14 @@ private ContactsListRequest( Optional remoteFields, Optional remoteId, Optional showEnumOrigins, + Optional status, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.emailAddress = emailAddress; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -102,9 +107,18 @@ private ContactsListRequest( this.remoteFields = remoteFields; this.remoteId = remoteId; this.showEnumOrigins = showEnumOrigins; + this.status = status; this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return contacts for this company. */ @@ -145,14 +159,6 @@ public Optional getEmailAddress() { return emailAddress; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -257,6 +263,14 @@ public Optional getShowEnumOrigins() { return showEnumOrigins; } + /** + * @return If provided, will only return Contacts that match this status. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -269,12 +283,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ContactsListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && emailAddress.equals(other.emailAddress) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -287,18 +301,19 @@ private boolean equalTo(ContactsListRequest other) { && pageSize.equals(other.pageSize) && remoteFields.equals(other.remoteFields) && remoteId.equals(other.remoteId) - && showEnumOrigins.equals(other.showEnumOrigins); + && showEnumOrigins.equals(other.showEnumOrigins) + && status.equals(other.status); } @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, this.emailAddress, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -311,7 +326,8 @@ public int hashCode() { this.pageSize, this.remoteFields, this.remoteId, - this.showEnumOrigins); + this.showEnumOrigins, + this.status); } @java.lang.Override @@ -325,6 +341,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -335,8 +353,6 @@ public static final class Builder { private Optional emailAddress = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -363,18 +379,20 @@ public static final class Builder { private Optional showEnumOrigins = Optional.empty(); + private Optional status = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} public Builder from(ContactsListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); emailAddress(other.getEmailAddress()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -388,6 +406,23 @@ public Builder from(ContactsListRequest other) { remoteFields(other.getRemoteFields()); remoteId(other.getRemoteId()); showEnumOrigins(other.getShowEnumOrigins()); + status(other.getStatus()); + return this; + } + + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(ContactsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); return this; } @@ -446,17 +481,6 @@ public Builder emailAddress(String emailAddress) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(ContactsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -600,14 +624,25 @@ public Builder showEnumOrigins(String showEnumOrigins) { return this; } + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(String status) { + this.status = Optional.ofNullable(status); + return this; + } + public ContactsListRequest build() { return new ContactsListRequest( + expand, companyId, createdAfter, createdBefore, cursor, emailAddress, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, @@ -621,6 +656,7 @@ public ContactsListRequest build() { remoteFields, remoteId, showEnumOrigins, + status, additionalProperties); } } diff --git a/src/main/java/com/merge/api/resources/accounting/contacts/requests/ContactsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/contacts/requests/ContactsRetrieveRequest.java index b687bffe6..ddb83a50a 100644 --- a/src/main/java/com/merge/api/resources/accounting/contacts/requests/ContactsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/contacts/requests/ContactsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.contacts.types.ContactsRetrieveRequestExpand; +import com.merge.api.resources.accounting.contacts.types.ContactsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,12 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContactsRetrieveRequest.Builder.class) public final class ContactsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -34,15 +38,17 @@ public final class ContactsRetrieveRequest { private final Map additionalProperties; private ContactsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -52,7 +58,7 @@ private ContactsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -72,6 +78,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -103,6 +117,7 @@ private boolean equalTo(ContactsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @@ -110,7 +125,12 @@ private boolean equalTo(ContactsRetrieveRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.expand, this.includeRemoteData, this.includeRemoteFields, this.remoteFields, this.showEnumOrigins); + this.expand, + this.includeRemoteData, + this.includeRemoteFields, + this.includeShellData, + this.remoteFields, + this.showEnumOrigins); } @java.lang.Override @@ -124,12 +144,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -143,22 +165,28 @@ public Builder from(ContactsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(ContactsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(ContactsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -181,6 +209,17 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -208,6 +247,7 @@ public ContactsRetrieveRequest build() { expand, includeRemoteData, includeRemoteFields, + includeShellData, remoteFields, showEnumOrigins, additionalProperties); diff --git a/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsListRequestExpand.java deleted file mode 100644 index bfff8131f..000000000 --- a/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsListRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.contacts.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ContactsListRequestExpand { - ADDRESSES("addresses"), - - ADDRESSES_COMPANY("addresses,company"), - - ADDRESSES_PHONE_NUMBERS("addresses,phone_numbers"), - - ADDRESSES_PHONE_NUMBERS_COMPANY("addresses,phone_numbers,company"), - - COMPANY("company"), - - PHONE_NUMBERS("phone_numbers"), - - PHONE_NUMBERS_COMPANY("phone_numbers,company"); - - private final String value; - - ContactsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsListRequestExpandItem.java new file mode 100644 index 000000000..9f2689fa1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsListRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.contacts.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ContactsListRequestExpandItem { + ADDRESSES("addresses"), + + COMPANY("company"), + + PHONE_NUMBERS("phone_numbers"); + + private final String value; + + ContactsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsRetrieveRequestExpand.java deleted file mode 100644 index f681e48b8..000000000 --- a/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsRetrieveRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.contacts.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ContactsRetrieveRequestExpand { - ADDRESSES("addresses"), - - ADDRESSES_COMPANY("addresses,company"), - - ADDRESSES_PHONE_NUMBERS("addresses,phone_numbers"), - - ADDRESSES_PHONE_NUMBERS_COMPANY("addresses,phone_numbers,company"), - - COMPANY("company"), - - PHONE_NUMBERS("phone_numbers"), - - PHONE_NUMBERS_COMPANY("phone_numbers,company"); - - private final String value; - - ContactsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..0156171fe --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/contacts/types/ContactsRetrieveRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.contacts.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ContactsRetrieveRequestExpandItem { + ADDRESSES("addresses"), + + COMPANY("company"), + + PHONE_NUMBERS("phone_numbers"); + + private final String value; + + ContactsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/creditnotes/AsyncCreditNotesClient.java b/src/main/java/com/merge/api/resources/accounting/creditnotes/AsyncCreditNotesClient.java new file mode 100644 index 000000000..d7627642c --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/creditnotes/AsyncCreditNotesClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.creditnotes; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.creditnotes.requests.CreditNoteEndpointRequest; +import com.merge.api.resources.accounting.creditnotes.requests.CreditNotesListRequest; +import com.merge.api.resources.accounting.creditnotes.requests.CreditNotesRetrieveRequest; +import com.merge.api.resources.accounting.types.CreditNote; +import com.merge.api.resources.accounting.types.CreditNoteResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedCreditNoteList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCreditNotesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCreditNotesClient rawClient; + + public AsyncCreditNotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCreditNotesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCreditNotesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of CreditNote objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of CreditNote objects. + */ + public CompletableFuture list(CreditNotesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of CreditNote objects. + */ + public CompletableFuture list( + CreditNotesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a CreditNote object with the given values. + */ + public CompletableFuture create(CreditNoteEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a CreditNote object with the given values. + */ + public CompletableFuture create( + CreditNoteEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a CreditNote object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a CreditNote object with the given id. + */ + public CompletableFuture retrieve(String id, CreditNotesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a CreditNote object with the given id. + */ + public CompletableFuture retrieve( + String id, CreditNotesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for CreditNote POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for CreditNote POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/creditnotes/AsyncRawCreditNotesClient.java b/src/main/java/com/merge/api/resources/accounting/creditnotes/AsyncRawCreditNotesClient.java new file mode 100644 index 000000000..3459652c0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/creditnotes/AsyncRawCreditNotesClient.java @@ -0,0 +1,417 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.creditnotes; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.creditnotes.requests.CreditNoteEndpointRequest; +import com.merge.api.resources.accounting.creditnotes.requests.CreditNotesListRequest; +import com.merge.api.resources.accounting.creditnotes.requests.CreditNotesRetrieveRequest; +import com.merge.api.resources.accounting.types.CreditNote; +import com.merge.api.resources.accounting.types.CreditNoteResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedCreditNoteList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCreditNotesClient { + protected final ClientOptions clientOptions; + + public AsyncRawCreditNotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of CreditNote objects. + */ + public CompletableFuture> list() { + return list(CreditNotesListRequest.builder().build()); + } + + /** + * Returns a list of CreditNote objects. + */ + public CompletableFuture> list(CreditNotesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of CreditNote objects. + */ + public CompletableFuture> list( + CreditNotesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/credit-notes"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedCreditNoteList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a CreditNote object with the given values. + */ + public CompletableFuture> create(CreditNoteEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a CreditNote object with the given values. + */ + public CompletableFuture> create( + CreditNoteEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/credit-notes"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreditNoteResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a CreditNote object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, CreditNotesRetrieveRequest.builder().build()); + } + + /** + * Returns a CreditNote object with the given id. + */ + public CompletableFuture> retrieve(String id, CreditNotesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a CreditNote object with the given id. + */ + public CompletableFuture> retrieve( + String id, CreditNotesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/credit-notes") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreditNote.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for CreditNote POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for CreditNote POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/credit-notes/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/creditnotes/CreditNotesClient.java b/src/main/java/com/merge/api/resources/accounting/creditnotes/CreditNotesClient.java index 07f5bdcc3..9e731821a 100644 --- a/src/main/java/com/merge/api/resources/accounting/creditnotes/CreditNotesClient.java +++ b/src/main/java/com/merge/api/resources/accounting/creditnotes/CreditNotesClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.creditnotes; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.creditnotes.requests.CreditNoteEndpointRequest; import com.merge.api.resources.accounting.creditnotes.requests.CreditNotesListRequest; @@ -16,290 +12,91 @@ import com.merge.api.resources.accounting.types.CreditNoteResponse; import com.merge.api.resources.accounting.types.MetaResponse; import com.merge.api.resources.accounting.types.PaginatedCreditNoteList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class CreditNotesClient { protected final ClientOptions clientOptions; + private final RawCreditNotesClient rawClient; + public CreditNotesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCreditNotesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCreditNotesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of CreditNote objects. */ public PaginatedCreditNoteList list() { - return list(CreditNotesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of CreditNote objects. */ public PaginatedCreditNoteList list(CreditNotesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of CreditNote objects. */ public PaginatedCreditNoteList list(CreditNotesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/credit-notes"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - if (request.getTransactionDateAfter().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_after", - request.getTransactionDateAfter().get().toString()); - } - if (request.getTransactionDateBefore().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_before", - request.getTransactionDateBefore().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCreditNoteList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a CreditNote object with the given values. */ public CreditNoteResponse create(CreditNoteEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a CreditNote object with the given values. */ public CreditNoteResponse create(CreditNoteEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/credit-notes"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreditNoteResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a CreditNote object with the given id. */ public CreditNote retrieve(String id) { - return retrieve(id, CreditNotesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a CreditNote object with the given id. */ public CreditNote retrieve(String id, CreditNotesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a CreditNote object with the given id. */ public CreditNote retrieve(String id, CreditNotesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/credit-notes") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreditNote.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for CreditNote POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for CreditNote POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/credit-notes/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/creditnotes/RawCreditNotesClient.java b/src/main/java/com/merge/api/resources/accounting/creditnotes/RawCreditNotesClient.java new file mode 100644 index 000000000..e2ebd3c21 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/creditnotes/RawCreditNotesClient.java @@ -0,0 +1,357 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.creditnotes; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.creditnotes.requests.CreditNoteEndpointRequest; +import com.merge.api.resources.accounting.creditnotes.requests.CreditNotesListRequest; +import com.merge.api.resources.accounting.creditnotes.requests.CreditNotesRetrieveRequest; +import com.merge.api.resources.accounting.types.CreditNote; +import com.merge.api.resources.accounting.types.CreditNoteResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedCreditNoteList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCreditNotesClient { + protected final ClientOptions clientOptions; + + public RawCreditNotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of CreditNote objects. + */ + public MergeApiHttpResponse list() { + return list(CreditNotesListRequest.builder().build()); + } + + /** + * Returns a list of CreditNote objects. + */ + public MergeApiHttpResponse list(CreditNotesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of CreditNote objects. + */ + public MergeApiHttpResponse list( + CreditNotesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/credit-notes"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCreditNoteList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a CreditNote object with the given values. + */ + public MergeApiHttpResponse create(CreditNoteEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a CreditNote object with the given values. + */ + public MergeApiHttpResponse create( + CreditNoteEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/credit-notes"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreditNoteResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a CreditNote object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, CreditNotesRetrieveRequest.builder().build()); + } + + /** + * Returns a CreditNote object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, CreditNotesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a CreditNote object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, CreditNotesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/credit-notes") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreditNote.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for CreditNote POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for CreditNote POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/credit-notes/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/creditnotes/requests/CreditNotesListRequest.java b/src/main/java/com/merge/api/resources/accounting/creditnotes/requests/CreditNotesListRequest.java index 7ab256346..49b6e3584 100644 --- a/src/main/java/com/merge/api/resources/accounting/creditnotes/requests/CreditNotesListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/creditnotes/requests/CreditNotesListRequest.java @@ -12,11 +12,13 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.creditnotes.types.CreditNotesListRequestExpand; +import com.merge.api.resources.accounting.creditnotes.types.CreditNotesListRequestExpandItem; import com.merge.api.resources.accounting.creditnotes.types.CreditNotesListRequestRemoteFields; import com.merge.api.resources.accounting.creditnotes.types.CreditNotesListRequestShowEnumOrigins; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -24,6 +26,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreditNotesListRequest.Builder.class) public final class CreditNotesListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -32,8 +36,6 @@ public final class CreditNotesListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -59,11 +61,11 @@ public final class CreditNotesListRequest { private final Map additionalProperties; private CreditNotesListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -76,11 +78,11 @@ private CreditNotesListRequest( Optional transactionDateAfter, Optional transactionDateBefore, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -95,6 +97,14 @@ private CreditNotesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return credit notes for this company. */ @@ -127,14 +137,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -235,11 +237,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(CreditNotesListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -256,11 +258,11 @@ private boolean equalTo(CreditNotesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -285,6 +287,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -293,8 +297,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -323,11 +325,11 @@ public static final class Builder { private Builder() {} public Builder from(CreditNotesListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -342,6 +344,22 @@ public Builder from(CreditNotesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(CreditNotesListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -386,17 +404,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(CreditNotesListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -520,11 +527,11 @@ public Builder transactionDateBefore(OffsetDateTime transactionDateBefore) { public CreditNotesListRequest build() { return new CreditNotesListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/creditnotes/requests/CreditNotesRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/creditnotes/requests/CreditNotesRetrieveRequest.java index 75909edbb..b96899bd2 100644 --- a/src/main/java/com/merge/api/resources/accounting/creditnotes/requests/CreditNotesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/creditnotes/requests/CreditNotesRetrieveRequest.java @@ -12,10 +12,12 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.creditnotes.types.CreditNotesRetrieveRequestExpand; +import com.merge.api.resources.accounting.creditnotes.types.CreditNotesRetrieveRequestExpandItem; import com.merge.api.resources.accounting.creditnotes.types.CreditNotesRetrieveRequestRemoteFields; import com.merge.api.resources.accounting.creditnotes.types.CreditNotesRetrieveRequestShowEnumOrigins; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,10 +25,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CreditNotesRetrieveRequest.Builder.class) public final class CreditNotesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -34,13 +38,15 @@ public final class CreditNotesRetrieveRequest { private final Map additionalProperties; private CreditNotesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -50,7 +56,7 @@ private CreditNotesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -62,6 +68,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -92,13 +106,15 @@ public Map getAdditionalProperties() { private boolean equalTo(CreditNotesRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -112,10 +128,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -128,22 +146,28 @@ private Builder() {} public Builder from(CreditNotesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(CreditNotesRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(CreditNotesRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -155,6 +179,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -179,7 +214,7 @@ public Builder showEnumOrigins(CreditNotesRetrieveRequestShowEnumOrigins showEnu public CreditNotesRetrieveRequest build() { return new CreditNotesRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesListRequestExpand.java deleted file mode 100644 index a12c58ee5..000000000 --- a/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesListRequestExpand.java +++ /dev/null @@ -1,308 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.creditnotes.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CreditNotesListRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - APPLIED_PAYMENTS("applied_payments"), - - APPLIED_PAYMENTS_ACCOUNTING_PERIOD("applied_payments,accounting_period"), - - APPLIED_PAYMENTS_COMPANY("applied_payments,company"), - - APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("applied_payments,company,accounting_period"), - - APPLIED_PAYMENTS_CONTACT("applied_payments,contact"), - - APPLIED_PAYMENTS_CONTACT_ACCOUNTING_PERIOD("applied_payments,contact,accounting_period"), - - APPLIED_PAYMENTS_CONTACT_COMPANY("applied_payments,contact,company"), - - APPLIED_PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD("applied_payments,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS("applied_payments,line_items"), - - APPLIED_PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("applied_payments,line_items,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY("applied_payments,line_items,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("applied_payments,line_items,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT("applied_payments,line_items,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("applied_payments,line_items,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("applied_payments,line_items,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES("applied_payments,line_items,tracking_categories"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("applied_payments,line_items,tracking_categories,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("applied_payments,line_items,tracking_categories,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES("applied_payments,tracking_categories"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("applied_payments,tracking_categories,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("applied_payments,tracking_categories,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT("applied_payments,tracking_categories,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY("applied_payments,tracking_categories,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,company,accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - CONTACT("contact"), - - CONTACT_ACCOUNTING_PERIOD("contact,accounting_period"), - - CONTACT_COMPANY("contact,company"), - - CONTACT_COMPANY_ACCOUNTING_PERIOD("contact,company,accounting_period"), - - LINE_ITEMS("line_items"), - - LINE_ITEMS_ACCOUNTING_PERIOD("line_items,accounting_period"), - - LINE_ITEMS_COMPANY("line_items,company"), - - LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("line_items,company,accounting_period"), - - LINE_ITEMS_CONTACT("line_items,contact"), - - LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("line_items,contact,accounting_period"), - - LINE_ITEMS_CONTACT_COMPANY("line_items,contact,company"), - - LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD("line_items,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES("line_items,tracking_categories"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("line_items,tracking_categories,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("line_items,tracking_categories,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("line_items,tracking_categories,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY("line_items,tracking_categories,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,company,accounting_period"), - - PAYMENTS("payments"), - - PAYMENTS_ACCOUNTING_PERIOD("payments,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS("payments,applied_payments"), - - PAYMENTS_APPLIED_PAYMENTS_ACCOUNTING_PERIOD("payments,applied_payments,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY("payments,applied_payments,company"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,applied_payments,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT("payments,applied_payments,contact"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_ACCOUNTING_PERIOD("payments,applied_payments,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY("payments,applied_payments,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS("payments,applied_payments,line_items"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("payments,applied_payments,line_items,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY("payments,applied_payments,line_items,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT("payments,applied_payments,line_items,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("payments,applied_payments,line_items,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES( - "payments,applied_payments,line_items,tracking_categories"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY( - "payments,applied_payments,line_items,tracking_categories,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT( - "payments,applied_payments,line_items,tracking_categories,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES("payments,applied_payments,tracking_categories"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,applied_payments,tracking_categories,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT("payments,applied_payments,tracking_categories,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_COMPANY("payments,company"), - - PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,company,accounting_period"), - - PAYMENTS_CONTACT("payments,contact"), - - PAYMENTS_CONTACT_ACCOUNTING_PERIOD("payments,contact,accounting_period"), - - PAYMENTS_CONTACT_COMPANY("payments,contact,company"), - - PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD("payments,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS("payments,line_items"), - - PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("payments,line_items,accounting_period"), - - PAYMENTS_LINE_ITEMS_COMPANY("payments,line_items,company"), - - PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("payments,line_items,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT("payments,line_items,contact"), - - PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("payments,line_items,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("payments,line_items,contact,company"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD("payments,line_items,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES("payments,line_items,tracking_categories"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("payments,line_items,tracking_categories,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("payments,line_items,tracking_categories,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY("payments,line_items,tracking_categories,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES("payments,tracking_categories"), - - PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("payments,tracking_categories,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,tracking_categories,company"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("payments,tracking_categories,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT("payments,tracking_categories,contact"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("payments,tracking_categories,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY("payments,tracking_categories,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,contact,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_CONTACT("tracking_categories,contact"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("tracking_categories,contact,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY("tracking_categories,contact,company"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,contact,company,accounting_period"); - - private final String value; - - CreditNotesListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesListRequestExpandItem.java new file mode 100644 index 000000000..efde94693 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesListRequestExpandItem.java @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.creditnotes.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CreditNotesListRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + APPLIED_PAYMENTS("applied_payments"), + + COMPANY("company"), + + CONTACT("contact"), + + LINE_ITEMS("line_items"), + + PAYMENTS("payments"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + CreditNotesListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesRetrieveRequestExpand.java deleted file mode 100644 index d71033627..000000000 --- a/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesRetrieveRequestExpand.java +++ /dev/null @@ -1,308 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.creditnotes.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CreditNotesRetrieveRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - APPLIED_PAYMENTS("applied_payments"), - - APPLIED_PAYMENTS_ACCOUNTING_PERIOD("applied_payments,accounting_period"), - - APPLIED_PAYMENTS_COMPANY("applied_payments,company"), - - APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("applied_payments,company,accounting_period"), - - APPLIED_PAYMENTS_CONTACT("applied_payments,contact"), - - APPLIED_PAYMENTS_CONTACT_ACCOUNTING_PERIOD("applied_payments,contact,accounting_period"), - - APPLIED_PAYMENTS_CONTACT_COMPANY("applied_payments,contact,company"), - - APPLIED_PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD("applied_payments,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS("applied_payments,line_items"), - - APPLIED_PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("applied_payments,line_items,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY("applied_payments,line_items,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("applied_payments,line_items,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT("applied_payments,line_items,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("applied_payments,line_items,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("applied_payments,line_items,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES("applied_payments,line_items,tracking_categories"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("applied_payments,line_items,tracking_categories,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("applied_payments,line_items,tracking_categories,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES("applied_payments,tracking_categories"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("applied_payments,tracking_categories,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("applied_payments,tracking_categories,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT("applied_payments,tracking_categories,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY("applied_payments,tracking_categories,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,company,accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - CONTACT("contact"), - - CONTACT_ACCOUNTING_PERIOD("contact,accounting_period"), - - CONTACT_COMPANY("contact,company"), - - CONTACT_COMPANY_ACCOUNTING_PERIOD("contact,company,accounting_period"), - - LINE_ITEMS("line_items"), - - LINE_ITEMS_ACCOUNTING_PERIOD("line_items,accounting_period"), - - LINE_ITEMS_COMPANY("line_items,company"), - - LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("line_items,company,accounting_period"), - - LINE_ITEMS_CONTACT("line_items,contact"), - - LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("line_items,contact,accounting_period"), - - LINE_ITEMS_CONTACT_COMPANY("line_items,contact,company"), - - LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD("line_items,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES("line_items,tracking_categories"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("line_items,tracking_categories,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("line_items,tracking_categories,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("line_items,tracking_categories,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY("line_items,tracking_categories,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,company,accounting_period"), - - PAYMENTS("payments"), - - PAYMENTS_ACCOUNTING_PERIOD("payments,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS("payments,applied_payments"), - - PAYMENTS_APPLIED_PAYMENTS_ACCOUNTING_PERIOD("payments,applied_payments,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY("payments,applied_payments,company"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,applied_payments,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT("payments,applied_payments,contact"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_ACCOUNTING_PERIOD("payments,applied_payments,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY("payments,applied_payments,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS("payments,applied_payments,line_items"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("payments,applied_payments,line_items,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY("payments,applied_payments,line_items,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT("payments,applied_payments,line_items,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("payments,applied_payments,line_items,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES( - "payments,applied_payments,line_items,tracking_categories"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY( - "payments,applied_payments,line_items,tracking_categories,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT( - "payments,applied_payments,line_items,tracking_categories,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES("payments,applied_payments,tracking_categories"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,applied_payments,tracking_categories,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT("payments,applied_payments,tracking_categories,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_COMPANY("payments,company"), - - PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,company,accounting_period"), - - PAYMENTS_CONTACT("payments,contact"), - - PAYMENTS_CONTACT_ACCOUNTING_PERIOD("payments,contact,accounting_period"), - - PAYMENTS_CONTACT_COMPANY("payments,contact,company"), - - PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD("payments,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS("payments,line_items"), - - PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("payments,line_items,accounting_period"), - - PAYMENTS_LINE_ITEMS_COMPANY("payments,line_items,company"), - - PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("payments,line_items,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT("payments,line_items,contact"), - - PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("payments,line_items,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("payments,line_items,contact,company"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD("payments,line_items,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES("payments,line_items,tracking_categories"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("payments,line_items,tracking_categories,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("payments,line_items,tracking_categories,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY("payments,line_items,tracking_categories,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES("payments,tracking_categories"), - - PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("payments,tracking_categories,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,tracking_categories,company"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("payments,tracking_categories,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT("payments,tracking_categories,contact"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("payments,tracking_categories,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY("payments,tracking_categories,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,contact,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_CONTACT("tracking_categories,contact"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("tracking_categories,contact,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY("tracking_categories,contact,company"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,contact,company,accounting_period"); - - private final String value; - - CreditNotesRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesRetrieveRequestExpandItem.java new file mode 100644 index 000000000..98581b299 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/creditnotes/types/CreditNotesRetrieveRequestExpandItem.java @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.creditnotes.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CreditNotesRetrieveRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + APPLIED_PAYMENTS("applied_payments"), + + COMPANY("company"), + + CONTACT("contact"), + + LINE_ITEMS("line_items"), + + PAYMENTS("payments"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + CreditNotesRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/deleteaccount/AsyncDeleteAccountClient.java b/src/main/java/com/merge/api/resources/accounting/deleteaccount/AsyncDeleteAccountClient.java new file mode 100644 index 000000000..29d710dc9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/deleteaccount/AsyncDeleteAccountClient.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.deleteaccount; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import java.util.concurrent.CompletableFuture; + +public class AsyncDeleteAccountClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDeleteAccountClient rawClient; + + public AsyncDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDeleteAccountClient withRawResponse() { + return this.rawClient; + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete() { + return this.rawClient.delete().thenApply(response -> response.body()); + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete(RequestOptions requestOptions) { + return this.rawClient.delete(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/deleteaccount/AsyncRawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/accounting/deleteaccount/AsyncRawDeleteAccountClient.java new file mode 100644 index 000000000..db9b442bd --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/deleteaccount/AsyncRawDeleteAccountClient.java @@ -0,0 +1,84 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public AsyncRawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/deleteaccount/DeleteAccountClient.java b/src/main/java/com/merge/api/resources/accounting/deleteaccount/DeleteAccountClient.java index 80a69903b..62cb04517 100644 --- a/src/main/java/com/merge/api/resources/accounting/deleteaccount/DeleteAccountClient.java +++ b/src/main/java/com/merge/api/resources/accounting/deleteaccount/DeleteAccountClient.java @@ -3,63 +3,37 @@ */ package com.merge.api.resources.accounting.deleteaccount; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class DeleteAccountClient { protected final ClientOptions clientOptions; + private final RawDeleteAccountClient rawClient; + public DeleteAccountClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDeleteAccountClient withRawResponse() { + return this.rawClient; } /** * Delete a linked account. */ public void delete() { - delete(null); + this.rawClient.delete().body(); } /** * Delete a linked account. */ public void delete(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/delete-account") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + this.rawClient.delete(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/deleteaccount/RawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/accounting/deleteaccount/RawDeleteAccountClient.java new file mode 100644 index 000000000..95386a040 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/deleteaccount/RawDeleteAccountClient.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public RawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/employees/AsyncEmployeesClient.java b/src/main/java/com/merge/api/resources/accounting/employees/AsyncEmployeesClient.java new file mode 100644 index 000000000..3d60c5b53 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/employees/AsyncEmployeesClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.employees; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.employees.requests.EmployeesListRequest; +import com.merge.api.resources.accounting.employees.requests.EmployeesRetrieveRequest; +import com.merge.api.resources.accounting.types.Employee; +import com.merge.api.resources.accounting.types.PaginatedEmployeeList; +import java.util.concurrent.CompletableFuture; + +public class AsyncEmployeesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawEmployeesClient rawClient; + + public AsyncEmployeesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawEmployeesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawEmployeesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture list(EmployeesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture list(EmployeesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture retrieve(String id, EmployeesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture retrieve( + String id, EmployeesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/employees/AsyncRawEmployeesClient.java b/src/main/java/com/merge/api/resources/accounting/employees/AsyncRawEmployeesClient.java new file mode 100644 index 000000000..719788c61 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/employees/AsyncRawEmployeesClient.java @@ -0,0 +1,214 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.employees; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.employees.requests.EmployeesListRequest; +import com.merge.api.resources.accounting.employees.requests.EmployeesRetrieveRequest; +import com.merge.api.resources.accounting.types.Employee; +import com.merge.api.resources.accounting.types.PaginatedEmployeeList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawEmployeesClient { + protected final ClientOptions clientOptions; + + public AsyncRawEmployeesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture> list() { + return list(EmployeesListRequest.builder().build()); + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture> list(EmployeesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture> list( + EmployeesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/employees"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEmployeeList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, EmployeesRetrieveRequest.builder().build()); + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture> retrieve(String id, EmployeesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture> retrieve( + String id, EmployeesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/employees") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Employee.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/employees/EmployeesClient.java b/src/main/java/com/merge/api/resources/accounting/employees/EmployeesClient.java index 98bb266b9..9b1f0919d 100644 --- a/src/main/java/com/merge/api/resources/accounting/employees/EmployeesClient.java +++ b/src/main/java/com/merge/api/resources/accounting/employees/EmployeesClient.java @@ -3,151 +3,69 @@ */ package com.merge.api.resources.accounting.employees; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.employees.requests.EmployeesListRequest; import com.merge.api.resources.accounting.employees.requests.EmployeesRetrieveRequest; import com.merge.api.resources.accounting.types.Employee; import com.merge.api.resources.accounting.types.PaginatedEmployeeList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class EmployeesClient { protected final ClientOptions clientOptions; + private final RawEmployeesClient rawClient; + public EmployeesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawEmployeesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawEmployeesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Employee objects. */ public PaginatedEmployeeList list() { - return list(EmployeesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Employee objects. */ public PaginatedEmployeeList list(EmployeesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Employee objects. */ public PaginatedEmployeeList list(EmployeesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/employees"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEmployeeList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an Employee object with the given id. */ public Employee retrieve(String id) { - return retrieve(id, EmployeesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Employee object with the given id. */ public Employee retrieve(String id, EmployeesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Employee object with the given id. */ public Employee retrieve(String id, EmployeesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/employees") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Employee.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/employees/RawEmployeesClient.java b/src/main/java/com/merge/api/resources/accounting/employees/RawEmployeesClient.java new file mode 100644 index 000000000..9d8795798 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/employees/RawEmployeesClient.java @@ -0,0 +1,184 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.employees; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.employees.requests.EmployeesListRequest; +import com.merge.api.resources.accounting.employees.requests.EmployeesRetrieveRequest; +import com.merge.api.resources.accounting.types.Employee; +import com.merge.api.resources.accounting.types.PaginatedEmployeeList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawEmployeesClient { + protected final ClientOptions clientOptions; + + public RawEmployeesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Employee objects. + */ + public MergeApiHttpResponse list() { + return list(EmployeesListRequest.builder().build()); + } + + /** + * Returns a list of Employee objects. + */ + public MergeApiHttpResponse list(EmployeesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Employee objects. + */ + public MergeApiHttpResponse list( + EmployeesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/employees"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEmployeeList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Employee object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, EmployeesRetrieveRequest.builder().build()); + } + + /** + * Returns an Employee object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, EmployeesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Employee object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, EmployeesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/employees") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Employee.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/employees/requests/EmployeesListRequest.java b/src/main/java/com/merge/api/resources/accounting/employees/requests/EmployeesListRequest.java index 452e24f0a..a9e3e841f 100644 --- a/src/main/java/com/merge/api/resources/accounting/employees/requests/EmployeesListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/employees/requests/EmployeesListRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,9 +22,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EmployeesListRequest.Builder.class) public final class EmployeesListRequest { - private final Optional cursor; + private final Optional> expand; - private final Optional expand; + private final Optional cursor; private final Optional includeDeletedData; @@ -35,15 +37,15 @@ public final class EmployeesListRequest { private final Map additionalProperties; private EmployeesListRequest( + Optional> expand, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, Optional pageSize, Map additionalProperties) { - this.cursor = cursor; this.expand = expand; + this.cursor = cursor; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -52,19 +54,19 @@ private EmployeesListRequest( } /** - * @return The pagination cursor value. + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; + @JsonProperty("expand") + public Optional> getExpand() { + return expand; } /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + * @return The pagination cursor value. */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; } /** @@ -111,8 +113,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(EmployeesListRequest other) { - return cursor.equals(other.cursor) - && expand.equals(other.expand) + return expand.equals(other.expand) + && cursor.equals(other.cursor) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -122,8 +124,8 @@ private boolean equalTo(EmployeesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.cursor, this.expand, + this.cursor, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -141,9 +143,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional cursor = Optional.empty(); + private Optional> expand = Optional.empty(); - private Optional expand = Optional.empty(); + private Optional cursor = Optional.empty(); private Optional includeDeletedData = Optional.empty(); @@ -159,8 +161,8 @@ public static final class Builder { private Builder() {} public Builder from(EmployeesListRequest other) { - cursor(other.getCursor()); expand(other.getExpand()); + cursor(other.getCursor()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -168,25 +170,30 @@ public Builder from(EmployeesListRequest other) { return this; } - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; return this; } - public Builder cursor(String cursor) { - this.cursor = Optional.ofNullable(cursor); + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); return this; } - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); return this; } @@ -236,8 +243,8 @@ public Builder pageSize(Integer pageSize) { public EmployeesListRequest build() { return new EmployeesListRequest( - cursor, expand, + cursor, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/employees/requests/EmployeesRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/employees/requests/EmployeesRetrieveRequest.java index 83a6c593a..6a9f6a29d 100644 --- a/src/main/java/com/merge/api/resources/accounting/employees/requests/EmployeesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/employees/requests/EmployeesRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EmployeesRetrieveRequest.Builder.class) public final class EmployeesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private EmployeesRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private EmployeesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(EmployeesRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(EmployeesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public EmployeesRetrieveRequest build() { - return new EmployeesRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new EmployeesRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/expenses/AsyncExpensesClient.java b/src/main/java/com/merge/api/resources/accounting/expenses/AsyncExpensesClient.java new file mode 100644 index 000000000..d39424aff --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/expenses/AsyncExpensesClient.java @@ -0,0 +1,155 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.expenses; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.expenses.requests.ExpenseEndpointRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesLinesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesListRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesRetrieveRequest; +import com.merge.api.resources.accounting.types.Expense; +import com.merge.api.resources.accounting.types.ExpenseResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedExpenseList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncExpensesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawExpensesClient rawClient; + + public AsyncExpensesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawExpensesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawExpensesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Expense objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Expense objects. + */ + public CompletableFuture list(ExpensesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Expense objects. + */ + public CompletableFuture list(ExpensesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Expense object with the given values. + */ + public CompletableFuture create(ExpenseEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Expense object with the given values. + */ + public CompletableFuture create(ExpenseEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Expense object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Expense object with the given id. + */ + public CompletableFuture retrieve(String id, ExpensesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Expense object with the given id. + */ + public CompletableFuture retrieve( + String id, ExpensesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture linesRemoteFieldClassesList() { + return this.rawClient.linesRemoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture linesRemoteFieldClassesList( + ExpensesLinesRemoteFieldClassesListRequest request) { + return this.rawClient.linesRemoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture linesRemoteFieldClassesList( + ExpensesLinesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient + .linesRemoteFieldClassesList(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns metadata for Expense POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Expense POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + ExpensesRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + ExpensesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/expenses/AsyncRawExpensesClient.java b/src/main/java/com/merge/api/resources/accounting/expenses/AsyncRawExpensesClient.java new file mode 100644 index 000000000..751a5d83b --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/expenses/AsyncRawExpensesClient.java @@ -0,0 +1,616 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.expenses; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.expenses.requests.ExpenseEndpointRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesLinesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesListRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesRetrieveRequest; +import com.merge.api.resources.accounting.types.Expense; +import com.merge.api.resources.accounting.types.ExpenseResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedExpenseList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawExpensesClient { + protected final ClientOptions clientOptions; + + public AsyncRawExpensesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Expense objects. + */ + public CompletableFuture> list() { + return list(ExpensesListRequest.builder().build()); + } + + /** + * Returns a list of Expense objects. + */ + public CompletableFuture> list(ExpensesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Expense objects. + */ + public CompletableFuture> list( + ExpensesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedExpenseList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Expense object with the given values. + */ + public CompletableFuture> create(ExpenseEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Expense object with the given values. + */ + public CompletableFuture> create( + ExpenseEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExpenseResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Expense object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, ExpensesRetrieveRequest.builder().build()); + } + + /** + * Returns an Expense object with the given id. + */ + public CompletableFuture> retrieve(String id, ExpensesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Expense object with the given id. + */ + public CompletableFuture> retrieve( + String id, ExpensesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Expense.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> linesRemoteFieldClassesList() { + return linesRemoteFieldClassesList( + ExpensesLinesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> linesRemoteFieldClassesList( + ExpensesLinesRemoteFieldClassesListRequest request) { + return linesRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> linesRemoteFieldClassesList( + ExpensesLinesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses/lines/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Expense POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Expense POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + ExpensesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + ExpensesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + ExpensesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/expenses/ExpensesClient.java b/src/main/java/com/merge/api/resources/accounting/expenses/ExpensesClient.java index 2c05b5358..fcf84c2b2 100644 --- a/src/main/java/com/merge/api/resources/accounting/expenses/ExpensesClient.java +++ b/src/main/java/com/merge/api/resources/accounting/expenses/ExpensesClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.expenses; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.expenses.requests.ExpenseEndpointRequest; import com.merge.api.resources.accounting.expenses.requests.ExpensesLinesRemoteFieldClassesListRequest; @@ -19,252 +15,85 @@ import com.merge.api.resources.accounting.types.MetaResponse; import com.merge.api.resources.accounting.types.PaginatedExpenseList; import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ExpensesClient { protected final ClientOptions clientOptions; + private final RawExpensesClient rawClient; + public ExpensesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawExpensesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawExpensesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Expense objects. */ public PaginatedExpenseList list() { - return list(ExpensesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Expense objects. */ public PaginatedExpenseList list(ExpensesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Expense objects. */ public PaginatedExpenseList list(ExpensesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/expenses"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getTransactionDateAfter().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_after", - request.getTransactionDateAfter().get().toString()); - } - if (request.getTransactionDateBefore().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_before", - request.getTransactionDateBefore().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedExpenseList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates an Expense object with the given values. */ public ExpenseResponse create(ExpenseEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates an Expense object with the given values. */ public ExpenseResponse create(ExpenseEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/expenses"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExpenseResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Expense object with the given id. */ public Expense retrieve(String id) { - return retrieve(id, ExpensesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Expense object with the given id. */ public Expense retrieve(String id, ExpensesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Expense object with the given id. */ public Expense retrieve(String id, ExpensesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/expenses") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Expense.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList linesRemoteFieldClassesList() { - return linesRemoteFieldClassesList( - ExpensesLinesRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.linesRemoteFieldClassesList().body(); } /** @@ -272,7 +101,7 @@ public PaginatedRemoteFieldClassList linesRemoteFieldClassesList() { */ public PaginatedRemoteFieldClassList linesRemoteFieldClassesList( ExpensesLinesRemoteFieldClassesListRequest request) { - return linesRemoteFieldClassesList(request, null); + return this.rawClient.linesRemoteFieldClassesList(request).body(); } /** @@ -280,113 +109,37 @@ public PaginatedRemoteFieldClassList linesRemoteFieldClassesList( */ public PaginatedRemoteFieldClassList linesRemoteFieldClassesList( ExpensesLinesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/expenses/lines/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .linesRemoteFieldClassesList(request, requestOptions) + .body(); } /** * Returns metadata for Expense POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Expense POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/expenses/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - ExpensesRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(ExpensesRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -394,56 +147,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(ExpensesRemoteFieldC */ public PaginatedRemoteFieldClassList remoteFieldClassesList( ExpensesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/expenses/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/expenses/RawExpensesClient.java b/src/main/java/com/merge/api/resources/accounting/expenses/RawExpensesClient.java new file mode 100644 index 000000000..f106b70fc --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/expenses/RawExpensesClient.java @@ -0,0 +1,528 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.expenses; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.expenses.requests.ExpenseEndpointRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesLinesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesListRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.expenses.requests.ExpensesRetrieveRequest; +import com.merge.api.resources.accounting.types.Expense; +import com.merge.api.resources.accounting.types.ExpenseResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedExpenseList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawExpensesClient { + protected final ClientOptions clientOptions; + + public RawExpensesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Expense objects. + */ + public MergeApiHttpResponse list() { + return list(ExpensesListRequest.builder().build()); + } + + /** + * Returns a list of Expense objects. + */ + public MergeApiHttpResponse list(ExpensesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Expense objects. + */ + public MergeApiHttpResponse list(ExpensesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedExpenseList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Expense object with the given values. + */ + public MergeApiHttpResponse create(ExpenseEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Expense object with the given values. + */ + public MergeApiHttpResponse create(ExpenseEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExpenseResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Expense object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, ExpensesRetrieveRequest.builder().build()); + } + + /** + * Returns an Expense object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, ExpensesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Expense object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, ExpensesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Expense.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse linesRemoteFieldClassesList() { + return linesRemoteFieldClassesList( + ExpensesLinesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse linesRemoteFieldClassesList( + ExpensesLinesRemoteFieldClassesListRequest request) { + return linesRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse linesRemoteFieldClassesList( + ExpensesLinesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses/lines/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Expense POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Expense POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + ExpensesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + ExpensesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + ExpensesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/expenses/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/expenses/requests/ExpensesListRequest.java b/src/main/java/com/merge/api/resources/accounting/expenses/requests/ExpensesListRequest.java index 036ea589c..d9c5fe4cc 100644 --- a/src/main/java/com/merge/api/resources/accounting/expenses/requests/ExpensesListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/expenses/requests/ExpensesListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.expenses.types.ExpensesListRequestExpand; +import com.merge.api.resources.accounting.expenses.types.ExpensesListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ExpensesListRequest.Builder.class) public final class ExpensesListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -30,8 +34,6 @@ public final class ExpensesListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -55,11 +57,11 @@ public final class ExpensesListRequest { private final Map additionalProperties; private ExpensesListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -71,11 +73,11 @@ private ExpensesListRequest( Optional transactionDateAfter, Optional transactionDateBefore, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -89,6 +91,14 @@ private ExpensesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return expenses for this company. */ @@ -121,14 +131,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -221,11 +223,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(ExpensesListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -241,11 +243,11 @@ private boolean equalTo(ExpensesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -269,6 +271,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -277,8 +281,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -305,11 +307,11 @@ public static final class Builder { private Builder() {} public Builder from(ExpensesListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -323,6 +325,22 @@ public Builder from(ExpensesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(ExpensesListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -367,17 +385,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(ExpensesListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -490,11 +497,11 @@ public Builder transactionDateBefore(OffsetDateTime transactionDateBefore) { public ExpensesListRequest build() { return new ExpensesListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/accounting/expenses/requests/ExpensesRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/expenses/requests/ExpensesRetrieveRequest.java index 0b94c8644..3232ec6b7 100644 --- a/src/main/java/com/merge/api/resources/accounting/expenses/requests/ExpensesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/expenses/requests/ExpensesRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.expenses.types.ExpensesRetrieveRequestExpand; +import com.merge.api.resources.accounting.expenses.types.ExpensesRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,22 +23,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ExpensesRetrieveRequest.Builder.class) public final class ExpensesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private ExpensesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -44,7 +50,7 @@ private ExpensesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -64,6 +70,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -78,12 +92,13 @@ public Map getAdditionalProperties() { private boolean equalTo(ExpensesRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -97,12 +112,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -112,20 +129,26 @@ public Builder from(ExpensesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(ExpensesRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(ExpensesRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -148,8 +171,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public ExpensesRetrieveRequest build() { - return new ExpensesRetrieveRequest(expand, includeRemoteData, includeRemoteFields, additionalProperties); + return new ExpensesRetrieveRequest( + expand, includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesListRequestExpand.java deleted file mode 100644 index 6ad80e938..000000000 --- a/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesListRequestExpand.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.expenses.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ExpensesListRequestExpand { - ACCOUNT("account"), - - ACCOUNT_ACCOUNTING_PERIOD("account,accounting_period"), - - ACCOUNT_COMPANY("account,company"), - - ACCOUNT_COMPANY_ACCOUNTING_PERIOD("account,company,accounting_period"), - - ACCOUNT_COMPANY_EMPLOYEE("account,company,employee"), - - ACCOUNT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("account,company,employee,accounting_period"), - - ACCOUNT_CONTACT("account,contact"), - - ACCOUNT_CONTACT_ACCOUNTING_PERIOD("account,contact,accounting_period"), - - ACCOUNT_CONTACT_COMPANY("account,contact,company"), - - ACCOUNT_CONTACT_COMPANY_ACCOUNTING_PERIOD("account,contact,company,accounting_period"), - - ACCOUNT_CONTACT_COMPANY_EMPLOYEE("account,contact,company,employee"), - - ACCOUNT_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("account,contact,company,employee,accounting_period"), - - ACCOUNT_CONTACT_EMPLOYEE("account,contact,employee"), - - ACCOUNT_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("account,contact,employee,accounting_period"), - - ACCOUNT_EMPLOYEE("account,employee"), - - ACCOUNT_EMPLOYEE_ACCOUNTING_PERIOD("account,employee,accounting_period"), - - ACCOUNTING_PERIOD("accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - COMPANY_EMPLOYEE("company,employee"), - - COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("company,employee,accounting_period"), - - CONTACT("contact"), - - CONTACT_ACCOUNTING_PERIOD("contact,accounting_period"), - - CONTACT_COMPANY("contact,company"), - - CONTACT_COMPANY_ACCOUNTING_PERIOD("contact,company,accounting_period"), - - CONTACT_COMPANY_EMPLOYEE("contact,company,employee"), - - CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("contact,company,employee,accounting_period"), - - CONTACT_EMPLOYEE("contact,employee"), - - CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("contact,employee,accounting_period"), - - EMPLOYEE("employee"), - - EMPLOYEE_ACCOUNTING_PERIOD("employee,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNT("tracking_categories,account"), - - TRACKING_CATEGORIES_ACCOUNT_ACCOUNTING_PERIOD("tracking_categories,account,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY("tracking_categories,account,company"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,account,company,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY_EMPLOYEE("tracking_categories,account,company,employee"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,account,company,employee,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT("tracking_categories,account,contact"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_ACCOUNTING_PERIOD("tracking_categories,account,contact,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_COMPANY("tracking_categories,account,contact,company"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,account,contact,company,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_COMPANY_EMPLOYEE("tracking_categories,account,contact,company,employee"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,account,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_EMPLOYEE("tracking_categories,account,contact,employee"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,account,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_EMPLOYEE("tracking_categories,account,employee"), - - TRACKING_CATEGORIES_ACCOUNT_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,account,employee,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_COMPANY_EMPLOYEE("tracking_categories,company,employee"), - - TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,company,employee,accounting_period"), - - TRACKING_CATEGORIES_CONTACT("tracking_categories,contact"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("tracking_categories,contact,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY("tracking_categories,contact,company"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,contact,company,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE("tracking_categories,contact,company,employee"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_EMPLOYEE("tracking_categories,contact,employee"), - - TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_EMPLOYEE("tracking_categories,employee"), - - TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,employee,accounting_period"); - - private final String value; - - ExpensesListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesListRequestExpandItem.java new file mode 100644 index 000000000..7bf548ecc --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesListRequestExpandItem.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.expenses.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ExpensesListRequestExpandItem { + ACCOUNT("account"), + + ACCOUNTING_PERIOD("accounting_period"), + + COMPANY("company"), + + CONTACT("contact"), + + EMPLOYEE("employee"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + ExpensesListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesRetrieveRequestExpand.java deleted file mode 100644 index 2549a8711..000000000 --- a/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesRetrieveRequestExpand.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.expenses.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ExpensesRetrieveRequestExpand { - ACCOUNT("account"), - - ACCOUNT_ACCOUNTING_PERIOD("account,accounting_period"), - - ACCOUNT_COMPANY("account,company"), - - ACCOUNT_COMPANY_ACCOUNTING_PERIOD("account,company,accounting_period"), - - ACCOUNT_COMPANY_EMPLOYEE("account,company,employee"), - - ACCOUNT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("account,company,employee,accounting_period"), - - ACCOUNT_CONTACT("account,contact"), - - ACCOUNT_CONTACT_ACCOUNTING_PERIOD("account,contact,accounting_period"), - - ACCOUNT_CONTACT_COMPANY("account,contact,company"), - - ACCOUNT_CONTACT_COMPANY_ACCOUNTING_PERIOD("account,contact,company,accounting_period"), - - ACCOUNT_CONTACT_COMPANY_EMPLOYEE("account,contact,company,employee"), - - ACCOUNT_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("account,contact,company,employee,accounting_period"), - - ACCOUNT_CONTACT_EMPLOYEE("account,contact,employee"), - - ACCOUNT_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("account,contact,employee,accounting_period"), - - ACCOUNT_EMPLOYEE("account,employee"), - - ACCOUNT_EMPLOYEE_ACCOUNTING_PERIOD("account,employee,accounting_period"), - - ACCOUNTING_PERIOD("accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - COMPANY_EMPLOYEE("company,employee"), - - COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("company,employee,accounting_period"), - - CONTACT("contact"), - - CONTACT_ACCOUNTING_PERIOD("contact,accounting_period"), - - CONTACT_COMPANY("contact,company"), - - CONTACT_COMPANY_ACCOUNTING_PERIOD("contact,company,accounting_period"), - - CONTACT_COMPANY_EMPLOYEE("contact,company,employee"), - - CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("contact,company,employee,accounting_period"), - - CONTACT_EMPLOYEE("contact,employee"), - - CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("contact,employee,accounting_period"), - - EMPLOYEE("employee"), - - EMPLOYEE_ACCOUNTING_PERIOD("employee,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNT("tracking_categories,account"), - - TRACKING_CATEGORIES_ACCOUNT_ACCOUNTING_PERIOD("tracking_categories,account,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY("tracking_categories,account,company"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,account,company,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY_EMPLOYEE("tracking_categories,account,company,employee"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,account,company,employee,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT("tracking_categories,account,contact"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_ACCOUNTING_PERIOD("tracking_categories,account,contact,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_COMPANY("tracking_categories,account,contact,company"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,account,contact,company,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_COMPANY_EMPLOYEE("tracking_categories,account,contact,company,employee"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,account,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_EMPLOYEE("tracking_categories,account,contact,employee"), - - TRACKING_CATEGORIES_ACCOUNT_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,account,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_EMPLOYEE("tracking_categories,account,employee"), - - TRACKING_CATEGORIES_ACCOUNT_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,account,employee,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_COMPANY_EMPLOYEE("tracking_categories,company,employee"), - - TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,company,employee,accounting_period"), - - TRACKING_CATEGORIES_CONTACT("tracking_categories,contact"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("tracking_categories,contact,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY("tracking_categories,contact,company"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,contact,company,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE("tracking_categories,contact,company,employee"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_EMPLOYEE("tracking_categories,contact,employee"), - - TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_EMPLOYEE("tracking_categories,employee"), - - TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,employee,accounting_period"); - - private final String value; - - ExpensesRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesRetrieveRequestExpandItem.java new file mode 100644 index 000000000..7cecfdd7c --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/expenses/types/ExpensesRetrieveRequestExpandItem.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.expenses.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ExpensesRetrieveRequestExpandItem { + ACCOUNT("account"), + + ACCOUNTING_PERIOD("accounting_period"), + + COMPANY("company"), + + CONTACT("contact"), + + EMPLOYEE("employee"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + ExpensesRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/fieldmapping/AsyncFieldMappingClient.java b/src/main/java/com/merge/api/resources/accounting/fieldmapping/AsyncFieldMappingClient.java new file mode 100644 index 000000000..de6e16888 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/fieldmapping/AsyncFieldMappingClient.java @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.fieldmapping; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.accounting.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.accounting.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.accounting.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.accounting.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.accounting.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.accounting.types.FieldMappingInstanceResponse; +import com.merge.api.resources.accounting.types.RemoteFieldApiResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncFieldMappingClient { + protected final ClientOptions clientOptions; + + private final AsyncRawFieldMappingClient rawClient; + + public AsyncFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawFieldMappingClient withRawResponse() { + return this.rawClient; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve() { + return this.rawClient.fieldMappingsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return this.rawClient.fieldMappingsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate(CreateFieldMappingRequest request) { + return this.rawClient.fieldMappingsCreate(request).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsCreate(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy(String fieldMappingId) { + return this.rawClient.fieldMappingsDestroy(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate(String fieldMappingId) { + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve() { + return this.rawClient.remoteFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return this.rawClient.remoteFieldsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve() { + return this.rawClient.targetFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve(RequestOptions requestOptions) { + return this.rawClient.targetFieldsRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/fieldmapping/AsyncRawFieldMappingClient.java b/src/main/java/com/merge/api/resources/accounting/fieldmapping/AsyncRawFieldMappingClient.java new file mode 100644 index 000000000..acf7d1a6d --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/fieldmapping/AsyncRawFieldMappingClient.java @@ -0,0 +1,471 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.accounting.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.accounting.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.accounting.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.accounting.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.accounting.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.accounting.types.FieldMappingInstanceResponse; +import com.merge.api.resources.accounting.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawFieldMappingClient { + protected final ClientOptions clientOptions; + + public AsyncRawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), RemoteFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/fieldmapping/FieldMappingClient.java b/src/main/java/com/merge/api/resources/accounting/fieldmapping/FieldMappingClient.java index 5cab701ad..837da5ece 100644 --- a/src/main/java/com/merge/api/resources/accounting/fieldmapping/FieldMappingClient.java +++ b/src/main/java/com/merge/api/resources/accounting/fieldmapping/FieldMappingClient.java @@ -3,12 +3,7 @@ */ package com.merge.api.resources.accounting.fieldmapping; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.fieldmapping.requests.CreateFieldMappingRequest; import com.merge.api.resources.accounting.fieldmapping.requests.FieldMappingsRetrieveRequest; @@ -18,36 +13,36 @@ import com.merge.api.resources.accounting.types.FieldMappingApiInstanceResponse; import com.merge.api.resources.accounting.types.FieldMappingInstanceResponse; import com.merge.api.resources.accounting.types.RemoteFieldApiResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class FieldMappingClient { protected final ClientOptions clientOptions; + private final RawFieldMappingClient rawClient; + public FieldMappingClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawFieldMappingClient withRawResponse() { + return this.rawClient; } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve() { - return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + return this.rawClient.fieldMappingsRetrieve().body(); } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrieveRequest request) { - return fieldMappingsRetrieve(request, null); + return this.rawClient.fieldMappingsRetrieve(request).body(); } /** @@ -55,46 +50,14 @@ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrie */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve( FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), FieldMappingApiInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).body(); } /** * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingRequest request) { - return fieldMappingsCreate(request, null); + return this.rawClient.fieldMappingsCreate(request).body(); } /** @@ -102,102 +65,30 @@ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingReques */ public FieldMappingInstanceResponse fieldMappingsCreate( CreateFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("target_field_name", request.getTargetFieldName()); - properties.put("target_field_description", request.getTargetFieldDescription()); - properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); - properties.put("remote_method", request.getRemoteMethod()); - properties.put("remote_url_path", request.getRemoteUrlPath()); - properties.put("common_model_name", request.getCommonModelName()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsCreate(request, requestOptions).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId) { - return fieldMappingsDestroy(fieldMappingId, null); + return this.rawClient.fieldMappingsDestroy(fieldMappingId).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .body(); } /** * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappingId) { - return fieldMappingsPartialUpdate( - fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).body(); } /** @@ -205,7 +96,9 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappi */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request) { - return fieldMappingsPartialUpdate(fieldMappingId, request, null); + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .body(); } /** @@ -213,56 +106,23 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve() { - return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + return this.rawClient.remoteFieldsRetrieve().body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { - return remoteFieldsRetrieve(request, null); + return this.rawClient.remoteFieldsRetrieve(request).body(); } /** @@ -270,80 +130,20 @@ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest r */ public RemoteFieldApiResponse remoteFieldsRetrieve( RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/remote-fields"); - if (request.getCommonModels().isPresent()) { - httpUrl.addQueryParameter("common_models", request.getCommonModels().get()); - } - if (request.getIncludeExampleValues().isPresent()) { - httpUrl.addQueryParameter( - "include_example_values", request.getIncludeExampleValues().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve() { - return targetFieldsRetrieve(null); + return this.rawClient.targetFieldsRetrieve().body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/target-fields") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalTargetFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.targetFieldsRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/fieldmapping/RawFieldMappingClient.java b/src/main/java/com/merge/api/resources/accounting/fieldmapping/RawFieldMappingClient.java new file mode 100644 index 000000000..c4eee4612 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/fieldmapping/RawFieldMappingClient.java @@ -0,0 +1,380 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.accounting.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.accounting.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.accounting.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.accounting.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.accounting.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.accounting.types.FieldMappingInstanceResponse; +import com.merge.api.resources.accounting.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawFieldMappingClient { + protected final ClientOptions clientOptions; + + public RawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate(CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy(String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate(String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/forceresync/AsyncForceResyncClient.java b/src/main/java/com/merge/api/resources/accounting/forceresync/AsyncForceResyncClient.java new file mode 100644 index 000000000..3d7516182 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/forceresync/AsyncForceResyncClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.forceresync; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.SyncStatus; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncForceResyncClient { + protected final ClientOptions clientOptions; + + private final AsyncRawForceResyncClient rawClient; + + public AsyncForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawForceResyncClient withRawResponse() { + return this.rawClient; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate() { + return this.rawClient.syncStatusResyncCreate().thenApply(response -> response.body()); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate(RequestOptions requestOptions) { + return this.rawClient.syncStatusResyncCreate(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/forceresync/AsyncRawForceResyncClient.java b/src/main/java/com/merge/api/resources/accounting/forceresync/AsyncRawForceResyncClient.java new file mode 100644 index 000000000..39ef2627b --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/forceresync/AsyncRawForceResyncClient.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawForceResyncClient { + protected final ClientOptions clientOptions; + + public AsyncRawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/forceresync/ForceResyncClient.java b/src/main/java/com/merge/api/resources/accounting/forceresync/ForceResyncClient.java index 303837539..4876c85c7 100644 --- a/src/main/java/com/merge/api/resources/accounting/forceresync/ForceResyncClient.java +++ b/src/main/java/com/merge/api/resources/accounting/forceresync/ForceResyncClient.java @@ -3,69 +3,39 @@ */ package com.merge.api.resources.accounting.forceresync; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.types.SyncStatus; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ForceResyncClient { protected final ClientOptions clientOptions; + private final RawForceResyncClient rawClient; + public ForceResyncClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawForceResyncClient withRawResponse() { + return this.rawClient; } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate() { - return syncStatusResyncCreate(null); + return this.rawClient.syncStatusResyncCreate().body(); } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/sync-status/resync") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.syncStatusResyncCreate(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/forceresync/RawForceResyncClient.java b/src/main/java/com/merge/api/resources/accounting/forceresync/RawForceResyncClient.java new file mode 100644 index 000000000..e01cf180e --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/forceresync/RawForceResyncClient.java @@ -0,0 +1,75 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawForceResyncClient { + protected final ClientOptions clientOptions; + + public RawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/AsyncGeneralLedgerTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/AsyncGeneralLedgerTransactionsClient.java new file mode 100644 index 000000000..8b600d9c5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/AsyncGeneralLedgerTransactionsClient.java @@ -0,0 +1,75 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.generalledgertransactions; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.generalledgertransactions.requests.GeneralLedgerTransactionsListRequest; +import com.merge.api.resources.accounting.generalledgertransactions.requests.GeneralLedgerTransactionsRetrieveRequest; +import com.merge.api.resources.accounting.types.GeneralLedgerTransaction; +import com.merge.api.resources.accounting.types.PaginatedGeneralLedgerTransactionList; +import java.util.concurrent.CompletableFuture; + +public class AsyncGeneralLedgerTransactionsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawGeneralLedgerTransactionsClient rawClient; + + public AsyncGeneralLedgerTransactionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawGeneralLedgerTransactionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawGeneralLedgerTransactionsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of GeneralLedgerTransaction objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of GeneralLedgerTransaction objects. + */ + public CompletableFuture list(GeneralLedgerTransactionsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of GeneralLedgerTransaction objects. + */ + public CompletableFuture list( + GeneralLedgerTransactionsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a GeneralLedgerTransaction object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a GeneralLedgerTransaction object with the given id. + */ + public CompletableFuture retrieve( + String id, GeneralLedgerTransactionsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a GeneralLedgerTransaction object with the given id. + */ + public CompletableFuture retrieve( + String id, GeneralLedgerTransactionsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/AsyncRawGeneralLedgerTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/AsyncRawGeneralLedgerTransactionsClient.java new file mode 100644 index 000000000..7d35bc795 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/AsyncRawGeneralLedgerTransactionsClient.java @@ -0,0 +1,261 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.generalledgertransactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.generalledgertransactions.requests.GeneralLedgerTransactionsListRequest; +import com.merge.api.resources.accounting.generalledgertransactions.requests.GeneralLedgerTransactionsRetrieveRequest; +import com.merge.api.resources.accounting.types.GeneralLedgerTransaction; +import com.merge.api.resources.accounting.types.PaginatedGeneralLedgerTransactionList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawGeneralLedgerTransactionsClient { + protected final ClientOptions clientOptions; + + public AsyncRawGeneralLedgerTransactionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of GeneralLedgerTransaction objects. + */ + public CompletableFuture> list() { + return list(GeneralLedgerTransactionsListRequest.builder().build()); + } + + /** + * Returns a list of GeneralLedgerTransaction objects. + */ + public CompletableFuture> list( + GeneralLedgerTransactionsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of GeneralLedgerTransaction objects. + */ + public CompletableFuture> list( + GeneralLedgerTransactionsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/general-ledger-transactions"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPostedDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "posted_date_after", + request.getPostedDateAfter().get().toString(), + false); + } + if (request.getPostedDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "posted_date_before", + request.getPostedDateBefore().get().toString(), + false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedGeneralLedgerTransactionList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a GeneralLedgerTransaction object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, GeneralLedgerTransactionsRetrieveRequest.builder().build()); + } + + /** + * Returns a GeneralLedgerTransaction object with the given id. + */ + public CompletableFuture> retrieve( + String id, GeneralLedgerTransactionsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a GeneralLedgerTransaction object with the given id. + */ + public CompletableFuture> retrieve( + String id, GeneralLedgerTransactionsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/general-ledger-transactions") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), GeneralLedgerTransaction.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/GeneralLedgerTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/GeneralLedgerTransactionsClient.java index 7a0d6560c..d3b27b049 100644 --- a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/GeneralLedgerTransactionsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/GeneralLedgerTransactionsClient.java @@ -3,42 +3,42 @@ */ package com.merge.api.resources.accounting.generalledgertransactions; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.generalledgertransactions.requests.GeneralLedgerTransactionsListRequest; import com.merge.api.resources.accounting.generalledgertransactions.requests.GeneralLedgerTransactionsRetrieveRequest; import com.merge.api.resources.accounting.types.GeneralLedgerTransaction; import com.merge.api.resources.accounting.types.PaginatedGeneralLedgerTransactionList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class GeneralLedgerTransactionsClient { protected final ClientOptions clientOptions; + private final RawGeneralLedgerTransactionsClient rawClient; + public GeneralLedgerTransactionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawGeneralLedgerTransactionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawGeneralLedgerTransactionsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of GeneralLedgerTransaction objects. */ public PaginatedGeneralLedgerTransactionList list() { - return list(GeneralLedgerTransactionsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of GeneralLedgerTransaction objects. */ public PaginatedGeneralLedgerTransactionList list(GeneralLedgerTransactionsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** @@ -46,100 +46,21 @@ public PaginatedGeneralLedgerTransactionList list(GeneralLedgerTransactionsListR */ public PaginatedGeneralLedgerTransactionList list( GeneralLedgerTransactionsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/general-ledger-transactions"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getPostedDateAfter().isPresent()) { - httpUrl.addQueryParameter( - "posted_date_after", request.getPostedDateAfter().get().toString()); - } - if (request.getPostedDateBefore().isPresent()) { - httpUrl.addQueryParameter( - "posted_date_before", request.getPostedDateBefore().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedGeneralLedgerTransactionList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a GeneralLedgerTransaction object with the given id. */ public GeneralLedgerTransaction retrieve(String id) { - return retrieve(id, GeneralLedgerTransactionsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a GeneralLedgerTransaction object with the given id. */ public GeneralLedgerTransaction retrieve(String id, GeneralLedgerTransactionsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** @@ -147,40 +68,6 @@ public GeneralLedgerTransaction retrieve(String id, GeneralLedgerTransactionsRet */ public GeneralLedgerTransaction retrieve( String id, GeneralLedgerTransactionsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/general-ledger-transactions") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GeneralLedgerTransaction.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/RawGeneralLedgerTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/RawGeneralLedgerTransactionsClient.java new file mode 100644 index 000000000..1ebe0776c --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/RawGeneralLedgerTransactionsClient.java @@ -0,0 +1,229 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.generalledgertransactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.generalledgertransactions.requests.GeneralLedgerTransactionsListRequest; +import com.merge.api.resources.accounting.generalledgertransactions.requests.GeneralLedgerTransactionsRetrieveRequest; +import com.merge.api.resources.accounting.types.GeneralLedgerTransaction; +import com.merge.api.resources.accounting.types.PaginatedGeneralLedgerTransactionList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawGeneralLedgerTransactionsClient { + protected final ClientOptions clientOptions; + + public RawGeneralLedgerTransactionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of GeneralLedgerTransaction objects. + */ + public MergeApiHttpResponse list() { + return list(GeneralLedgerTransactionsListRequest.builder().build()); + } + + /** + * Returns a list of GeneralLedgerTransaction objects. + */ + public MergeApiHttpResponse list( + GeneralLedgerTransactionsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of GeneralLedgerTransaction objects. + */ + public MergeApiHttpResponse list( + GeneralLedgerTransactionsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/general-ledger-transactions"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPostedDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "posted_date_after", + request.getPostedDateAfter().get().toString(), + false); + } + if (request.getPostedDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "posted_date_before", + request.getPostedDateBefore().get().toString(), + false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedGeneralLedgerTransactionList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a GeneralLedgerTransaction object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, GeneralLedgerTransactionsRetrieveRequest.builder().build()); + } + + /** + * Returns a GeneralLedgerTransaction object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, GeneralLedgerTransactionsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a GeneralLedgerTransaction object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, GeneralLedgerTransactionsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/general-ledger-transactions") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GeneralLedgerTransaction.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/requests/GeneralLedgerTransactionsListRequest.java b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/requests/GeneralLedgerTransactionsListRequest.java index a7cafe3bb..b38f60d42 100644 --- a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/requests/GeneralLedgerTransactionsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/requests/GeneralLedgerTransactionsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.generalledgertransactions.types.GeneralLedgerTransactionsListRequestExpand; +import com.merge.api.resources.accounting.generalledgertransactions.types.GeneralLedgerTransactionsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GeneralLedgerTransactionsListRequest.Builder.class) public final class GeneralLedgerTransactionsListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -30,8 +34,6 @@ public final class GeneralLedgerTransactionsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -53,11 +55,11 @@ public final class GeneralLedgerTransactionsListRequest { private final Map additionalProperties; private GeneralLedgerTransactionsListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -68,11 +70,11 @@ private GeneralLedgerTransactionsListRequest( Optional postedDateBefore, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -85,6 +87,14 @@ private GeneralLedgerTransactionsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return general ledger transactions for this company. */ @@ -117,14 +127,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -210,11 +212,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(GeneralLedgerTransactionsListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -229,11 +231,11 @@ private boolean equalTo(GeneralLedgerTransactionsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -256,6 +258,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -264,8 +268,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -290,11 +292,11 @@ public static final class Builder { private Builder() {} public Builder from(GeneralLedgerTransactionsListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -307,6 +309,22 @@ public Builder from(GeneralLedgerTransactionsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(GeneralLedgerTransactionsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -351,17 +369,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(GeneralLedgerTransactionsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -463,11 +470,11 @@ public Builder remoteId(String remoteId) { public GeneralLedgerTransactionsListRequest build() { return new GeneralLedgerTransactionsListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/requests/GeneralLedgerTransactionsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/requests/GeneralLedgerTransactionsRetrieveRequest.java index f8f37c80c..96b8ca711 100644 --- a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/requests/GeneralLedgerTransactionsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/requests/GeneralLedgerTransactionsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.generalledgertransactions.types.GeneralLedgerTransactionsRetrieveRequestExpand; +import com.merge.api.resources.accounting.generalledgertransactions.types.GeneralLedgerTransactionsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GeneralLedgerTransactionsRetrieveRequest.Builder.class) public final class GeneralLedgerTransactionsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private GeneralLedgerTransactionsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private GeneralLedgerTransactionsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -65,12 +79,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(GeneralLedgerTransactionsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -84,10 +100,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -96,20 +114,26 @@ private Builder() {} public Builder from(GeneralLedgerTransactionsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(GeneralLedgerTransactionsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(GeneralLedgerTransactionsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -121,8 +145,20 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public GeneralLedgerTransactionsRetrieveRequest build() { - return new GeneralLedgerTransactionsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new GeneralLedgerTransactionsRetrieveRequest( + expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsListRequestExpand.java deleted file mode 100644 index 593ca6407..000000000 --- a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsListRequestExpand.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.generalledgertransactions.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum GeneralLedgerTransactionsListRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - GENERAL_LEDGER_TRANSACTION_LINES("general_ledger_transaction_lines"), - - GENERAL_LEDGER_TRANSACTION_LINES_ACCOUNTING_PERIOD("general_ledger_transaction_lines,accounting_period"), - - GENERAL_LEDGER_TRANSACTION_LINES_COMPANY("general_ledger_transaction_lines,company"), - - GENERAL_LEDGER_TRANSACTION_LINES_COMPANY_ACCOUNTING_PERIOD( - "general_ledger_transaction_lines,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_GENERAL_LEDGER_TRANSACTION_LINES("tracking_categories,general_ledger_transaction_lines"), - - TRACKING_CATEGORIES_GENERAL_LEDGER_TRANSACTION_LINES_ACCOUNTING_PERIOD( - "tracking_categories,general_ledger_transaction_lines,accounting_period"), - - TRACKING_CATEGORIES_GENERAL_LEDGER_TRANSACTION_LINES_COMPANY( - "tracking_categories,general_ledger_transaction_lines,company"), - - TRACKING_CATEGORIES_GENERAL_LEDGER_TRANSACTION_LINES_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,general_ledger_transaction_lines,company,accounting_period"); - - private final String value; - - GeneralLedgerTransactionsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsListRequestExpandItem.java new file mode 100644 index 000000000..b76bb5639 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsListRequestExpandItem.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.generalledgertransactions.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum GeneralLedgerTransactionsListRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + COMPANY("company"), + + GENERAL_LEDGER_TRANSACTION_LINES("general_ledger_transaction_lines"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + GeneralLedgerTransactionsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsRetrieveRequestExpand.java deleted file mode 100644 index 098e4392d..000000000 --- a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsRetrieveRequestExpand.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.generalledgertransactions.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum GeneralLedgerTransactionsRetrieveRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - GENERAL_LEDGER_TRANSACTION_LINES("general_ledger_transaction_lines"), - - GENERAL_LEDGER_TRANSACTION_LINES_ACCOUNTING_PERIOD("general_ledger_transaction_lines,accounting_period"), - - GENERAL_LEDGER_TRANSACTION_LINES_COMPANY("general_ledger_transaction_lines,company"), - - GENERAL_LEDGER_TRANSACTION_LINES_COMPANY_ACCOUNTING_PERIOD( - "general_ledger_transaction_lines,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_GENERAL_LEDGER_TRANSACTION_LINES("tracking_categories,general_ledger_transaction_lines"), - - TRACKING_CATEGORIES_GENERAL_LEDGER_TRANSACTION_LINES_ACCOUNTING_PERIOD( - "tracking_categories,general_ledger_transaction_lines,accounting_period"), - - TRACKING_CATEGORIES_GENERAL_LEDGER_TRANSACTION_LINES_COMPANY( - "tracking_categories,general_ledger_transaction_lines,company"), - - TRACKING_CATEGORIES_GENERAL_LEDGER_TRANSACTION_LINES_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,general_ledger_transaction_lines,company,accounting_period"); - - private final String value; - - GeneralLedgerTransactionsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..6cdd55bb0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/generalledgertransactions/types/GeneralLedgerTransactionsRetrieveRequestExpandItem.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.generalledgertransactions.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum GeneralLedgerTransactionsRetrieveRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + COMPANY("company"), + + GENERAL_LEDGER_TRANSACTION_LINES("general_ledger_transaction_lines"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + GeneralLedgerTransactionsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/generatekey/AsyncGenerateKeyClient.java b/src/main/java/com/merge/api/resources/accounting/generatekey/AsyncGenerateKeyClient.java new file mode 100644 index 000000000..e9bfb6246 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/generatekey/AsyncGenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.generatekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.accounting.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncGenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawGenerateKeyClient rawClient; + + public AsyncGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawGenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/generatekey/AsyncRawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/accounting/generatekey/AsyncRawGenerateKeyClient.java new file mode 100644 index 000000000..d97844354 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/generatekey/AsyncRawGenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.accounting.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public CompletableFuture> create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public CompletableFuture> create( + GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/generatekey/GenerateKeyClient.java b/src/main/java/com/merge/api/resources/accounting/generatekey/GenerateKeyClient.java index 22171e8a3..28158679b 100644 --- a/src/main/java/com/merge/api/resources/accounting/generatekey/GenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/accounting/generatekey/GenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.accounting.generatekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.generatekey.requests.GenerateRemoteKeyRequest; import com.merge.api.resources.accounting.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class GenerateKeyClient { protected final ClientOptions clientOptions; + private final RawGenerateKeyClient rawClient; + public GenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawGenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/generate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/generatekey/RawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/accounting/generatekey/RawGenerateKeyClient.java new file mode 100644 index 000000000..953a61839 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/generatekey/RawGenerateKeyClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.accounting.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/incomestatements/AsyncIncomeStatementsClient.java b/src/main/java/com/merge/api/resources/accounting/incomestatements/AsyncIncomeStatementsClient.java new file mode 100644 index 000000000..677ae4316 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/incomestatements/AsyncIncomeStatementsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.incomestatements; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.incomestatements.requests.IncomeStatementsListRequest; +import com.merge.api.resources.accounting.incomestatements.requests.IncomeStatementsRetrieveRequest; +import com.merge.api.resources.accounting.types.IncomeStatement; +import com.merge.api.resources.accounting.types.PaginatedIncomeStatementList; +import java.util.concurrent.CompletableFuture; + +public class AsyncIncomeStatementsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawIncomeStatementsClient rawClient; + + public AsyncIncomeStatementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawIncomeStatementsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawIncomeStatementsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of IncomeStatement objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of IncomeStatement objects. + */ + public CompletableFuture list(IncomeStatementsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of IncomeStatement objects. + */ + public CompletableFuture list( + IncomeStatementsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an IncomeStatement object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an IncomeStatement object with the given id. + */ + public CompletableFuture retrieve(String id, IncomeStatementsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an IncomeStatement object with the given id. + */ + public CompletableFuture retrieve( + String id, IncomeStatementsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/incomestatements/AsyncRawIncomeStatementsClient.java b/src/main/java/com/merge/api/resources/accounting/incomestatements/AsyncRawIncomeStatementsClient.java new file mode 100644 index 000000000..176606e83 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/incomestatements/AsyncRawIncomeStatementsClient.java @@ -0,0 +1,245 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.incomestatements; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.incomestatements.requests.IncomeStatementsListRequest; +import com.merge.api.resources.accounting.incomestatements.requests.IncomeStatementsRetrieveRequest; +import com.merge.api.resources.accounting.types.IncomeStatement; +import com.merge.api.resources.accounting.types.PaginatedIncomeStatementList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawIncomeStatementsClient { + protected final ClientOptions clientOptions; + + public AsyncRawIncomeStatementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of IncomeStatement objects. + */ + public CompletableFuture> list() { + return list(IncomeStatementsListRequest.builder().build()); + } + + /** + * Returns a list of IncomeStatement objects. + */ + public CompletableFuture> list( + IncomeStatementsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of IncomeStatement objects. + */ + public CompletableFuture> list( + IncomeStatementsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/income-statements"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedIncomeStatementList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an IncomeStatement object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, IncomeStatementsRetrieveRequest.builder().build()); + } + + /** + * Returns an IncomeStatement object with the given id. + */ + public CompletableFuture> retrieve( + String id, IncomeStatementsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an IncomeStatement object with the given id. + */ + public CompletableFuture> retrieve( + String id, IncomeStatementsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/income-statements") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), IncomeStatement.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/incomestatements/IncomeStatementsClient.java b/src/main/java/com/merge/api/resources/accounting/incomestatements/IncomeStatementsClient.java index bb1c9005f..965dbc3c5 100644 --- a/src/main/java/com/merge/api/resources/accounting/incomestatements/IncomeStatementsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/incomestatements/IncomeStatementsClient.java @@ -3,173 +3,69 @@ */ package com.merge.api.resources.accounting.incomestatements; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.incomestatements.requests.IncomeStatementsListRequest; import com.merge.api.resources.accounting.incomestatements.requests.IncomeStatementsRetrieveRequest; import com.merge.api.resources.accounting.types.IncomeStatement; import com.merge.api.resources.accounting.types.PaginatedIncomeStatementList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class IncomeStatementsClient { protected final ClientOptions clientOptions; + private final RawIncomeStatementsClient rawClient; + public IncomeStatementsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawIncomeStatementsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawIncomeStatementsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of IncomeStatement objects. */ public PaginatedIncomeStatementList list() { - return list(IncomeStatementsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of IncomeStatement objects. */ public PaginatedIncomeStatementList list(IncomeStatementsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of IncomeStatement objects. */ public PaginatedIncomeStatementList list(IncomeStatementsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/income-statements"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIncomeStatementList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an IncomeStatement object with the given id. */ public IncomeStatement retrieve(String id) { - return retrieve(id, IncomeStatementsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an IncomeStatement object with the given id. */ public IncomeStatement retrieve(String id, IncomeStatementsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an IncomeStatement object with the given id. */ public IncomeStatement retrieve(String id, IncomeStatementsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/income-statements") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), IncomeStatement.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/incomestatements/RawIncomeStatementsClient.java b/src/main/java/com/merge/api/resources/accounting/incomestatements/RawIncomeStatementsClient.java new file mode 100644 index 000000000..c1eb17ee5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/incomestatements/RawIncomeStatementsClient.java @@ -0,0 +1,211 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.incomestatements; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.incomestatements.requests.IncomeStatementsListRequest; +import com.merge.api.resources.accounting.incomestatements.requests.IncomeStatementsRetrieveRequest; +import com.merge.api.resources.accounting.types.IncomeStatement; +import com.merge.api.resources.accounting.types.PaginatedIncomeStatementList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawIncomeStatementsClient { + protected final ClientOptions clientOptions; + + public RawIncomeStatementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of IncomeStatement objects. + */ + public MergeApiHttpResponse list() { + return list(IncomeStatementsListRequest.builder().build()); + } + + /** + * Returns a list of IncomeStatement objects. + */ + public MergeApiHttpResponse list(IncomeStatementsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of IncomeStatement objects. + */ + public MergeApiHttpResponse list( + IncomeStatementsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/income-statements"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIncomeStatementList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an IncomeStatement object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, IncomeStatementsRetrieveRequest.builder().build()); + } + + /** + * Returns an IncomeStatement object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, IncomeStatementsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an IncomeStatement object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, IncomeStatementsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/income-statements") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), IncomeStatement.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/incomestatements/requests/IncomeStatementsListRequest.java b/src/main/java/com/merge/api/resources/accounting/incomestatements/requests/IncomeStatementsListRequest.java index a4cec14f1..8afba882b 100644 --- a/src/main/java/com/merge/api/resources/accounting/incomestatements/requests/IncomeStatementsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/incomestatements/requests/IncomeStatementsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = IncomeStatementsListRequest.Builder.class) public final class IncomeStatementsListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -29,8 +33,6 @@ public final class IncomeStatementsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -48,11 +50,11 @@ public final class IncomeStatementsListRequest { private final Map additionalProperties; private IncomeStatementsListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -61,11 +63,11 @@ private IncomeStatementsListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -76,6 +78,14 @@ private IncomeStatementsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return income statements for this company. */ @@ -108,14 +118,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -184,11 +186,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(IncomeStatementsListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -201,11 +203,11 @@ private boolean equalTo(IncomeStatementsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -226,6 +228,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -234,8 +238,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -256,11 +258,11 @@ public static final class Builder { private Builder() {} public Builder from(IncomeStatementsListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -271,6 +273,22 @@ public Builder from(IncomeStatementsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -315,17 +333,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -405,11 +412,11 @@ public Builder remoteId(String remoteId) { public IncomeStatementsListRequest build() { return new IncomeStatementsListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/incomestatements/requests/IncomeStatementsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/incomestatements/requests/IncomeStatementsRetrieveRequest.java index 89e5e0c10..b4f293c39 100644 --- a/src/main/java/com/merge/api/resources/accounting/incomestatements/requests/IncomeStatementsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/incomestatements/requests/IncomeStatementsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = IncomeStatementsRetrieveRequest.Builder.class) public final class IncomeStatementsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private IncomeStatementsRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private IncomeStatementsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(IncomeStatementsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(IncomeStatementsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,20 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public IncomeStatementsRetrieveRequest build() { - return new IncomeStatementsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new IncomeStatementsRetrieveRequest( + expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/invoices/AsyncInvoicesClient.java b/src/main/java/com/merge/api/resources/accounting/invoices/AsyncInvoicesClient.java new file mode 100644 index 000000000..681228163 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/invoices/AsyncInvoicesClient.java @@ -0,0 +1,187 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.invoices; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.invoices.requests.InvoiceEndpointRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesLineItemsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesListRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesRetrieveRequest; +import com.merge.api.resources.accounting.invoices.requests.PatchedInvoiceEndpointRequest; +import com.merge.api.resources.accounting.types.Invoice; +import com.merge.api.resources.accounting.types.InvoiceResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedInvoiceList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncInvoicesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawInvoicesClient rawClient; + + public AsyncInvoicesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawInvoicesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawInvoicesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Invoice objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Invoice objects. + */ + public CompletableFuture list(InvoicesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Invoice objects. + */ + public CompletableFuture list(InvoicesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Invoice object with the given values. + * Including a PurchaseOrder id in the purchase_orders property will generate an Accounts Payable Invoice from the specified Purchase Order(s). + */ + public CompletableFuture create(InvoiceEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Invoice object with the given values. + * Including a PurchaseOrder id in the purchase_orders property will generate an Accounts Payable Invoice from the specified Purchase Order(s). + */ + public CompletableFuture create(InvoiceEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Invoice object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Invoice object with the given id. + */ + public CompletableFuture retrieve(String id, InvoicesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Invoice object with the given id. + */ + public CompletableFuture retrieve( + String id, InvoicesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates an Invoice object with the given id. + */ + public CompletableFuture partialUpdate(String id, PatchedInvoiceEndpointRequest request) { + return this.rawClient.partialUpdate(id, request).thenApply(response -> response.body()); + } + + /** + * Updates an Invoice object with the given id. + */ + public CompletableFuture partialUpdate( + String id, PatchedInvoiceEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.partialUpdate(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture lineItemsRemoteFieldClassesList() { + return this.rawClient.lineItemsRemoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture lineItemsRemoteFieldClassesList( + InvoicesLineItemsRemoteFieldClassesListRequest request) { + return this.rawClient.lineItemsRemoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture lineItemsRemoteFieldClassesList( + InvoicesLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient + .lineItemsRemoteFieldClassesList(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns metadata for Invoice PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id) { + return this.rawClient.metaPatchRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Invoice PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id, RequestOptions requestOptions) { + return this.rawClient.metaPatchRetrieve(id, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Invoice POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Invoice POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + InvoicesRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + InvoicesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/invoices/AsyncRawInvoicesClient.java b/src/main/java/com/merge/api/resources/accounting/invoices/AsyncRawInvoicesClient.java new file mode 100644 index 000000000..367dedfcb --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/invoices/AsyncRawInvoicesClient.java @@ -0,0 +1,786 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.invoices; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.invoices.requests.InvoiceEndpointRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesLineItemsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesListRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesRetrieveRequest; +import com.merge.api.resources.accounting.invoices.requests.PatchedInvoiceEndpointRequest; +import com.merge.api.resources.accounting.types.Invoice; +import com.merge.api.resources.accounting.types.InvoiceResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedInvoiceList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawInvoicesClient { + protected final ClientOptions clientOptions; + + public AsyncRawInvoicesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Invoice objects. + */ + public CompletableFuture> list() { + return list(InvoicesListRequest.builder().build()); + } + + /** + * Returns a list of Invoice objects. + */ + public CompletableFuture> list(InvoicesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Invoice objects. + */ + public CompletableFuture> list( + InvoicesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getContactId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "contact_id", request.getContactId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIssueDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "issue_date_after", + request.getIssueDateAfter().get().toString(), + false); + } + if (request.getIssueDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "issue_date_before", + request.getIssueDateBefore().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getNumber().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "number", request.getNumber().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "type", request.getType().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedInvoiceList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Invoice object with the given values. + * Including a PurchaseOrder id in the purchase_orders property will generate an Accounts Payable Invoice from the specified Purchase Order(s). + */ + public CompletableFuture> create(InvoiceEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Invoice object with the given values. + * Including a PurchaseOrder id in the purchase_orders property will generate an Accounts Payable Invoice from the specified Purchase Order(s). + */ + public CompletableFuture> create( + InvoiceEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InvoiceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Invoice object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, InvoicesRetrieveRequest.builder().build()); + } + + /** + * Returns an Invoice object with the given id. + */ + public CompletableFuture> retrieve(String id, InvoicesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Invoice object with the given id. + */ + public CompletableFuture> retrieve( + String id, InvoicesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Invoice.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Updates an Invoice object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedInvoiceEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates an Invoice object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedInvoiceEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InvoiceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> lineItemsRemoteFieldClassesList() { + return lineItemsRemoteFieldClassesList( + InvoicesLineItemsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> lineItemsRemoteFieldClassesList( + InvoicesLineItemsRemoteFieldClassesListRequest request) { + return lineItemsRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> lineItemsRemoteFieldClassesList( + InvoicesLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices/line-items/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Invoice PATCHs. + */ + public CompletableFuture> metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Invoice PATCHs. + */ + public CompletableFuture> metaPatchRetrieve( + String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Invoice POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Invoice POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + InvoicesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + InvoicesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + InvoicesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/invoices/InvoicesClient.java b/src/main/java/com/merge/api/resources/accounting/invoices/InvoicesClient.java index 4149149b1..930fe652b 100644 --- a/src/main/java/com/merge/api/resources/accounting/invoices/InvoicesClient.java +++ b/src/main/java/com/merge/api/resources/accounting/invoices/InvoicesClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.invoices; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.invoices.requests.InvoiceEndpointRequest; import com.merge.api.resources.accounting.invoices.requests.InvoicesLineItemsRemoteFieldClassesListRequest; @@ -20,145 +16,43 @@ import com.merge.api.resources.accounting.types.MetaResponse; import com.merge.api.resources.accounting.types.PaginatedInvoiceList; import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class InvoicesClient { protected final ClientOptions clientOptions; + private final RawInvoicesClient rawClient; + public InvoicesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawInvoicesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawInvoicesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Invoice objects. */ public PaginatedInvoiceList list() { - return list(InvoicesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Invoice objects. */ public PaginatedInvoiceList list(InvoicesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Invoice objects. */ public PaginatedInvoiceList list(InvoicesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/invoices"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getContactId().isPresent()) { - httpUrl.addQueryParameter("contact_id", request.getContactId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIssueDateAfter().isPresent()) { - httpUrl.addQueryParameter( - "issue_date_after", request.getIssueDateAfter().get().toString()); - } - if (request.getIssueDateBefore().isPresent()) { - httpUrl.addQueryParameter( - "issue_date_before", request.getIssueDateBefore().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getNumber().isPresent()) { - httpUrl.addQueryParameter("number", request.getNumber().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - if (request.getType().isPresent()) { - httpUrl.addQueryParameter("type", request.getType().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedInvoiceList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** @@ -166,7 +60,7 @@ public PaginatedInvoiceList list(InvoicesListRequest request, RequestOptions req * Including a PurchaseOrder id in the purchase_orders property will generate an Accounts Payable Invoice from the specified Purchase Order(s). */ public InvoiceResponse create(InvoiceEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** @@ -174,123 +68,35 @@ public InvoiceResponse create(InvoiceEndpointRequest request) { * Including a PurchaseOrder id in the purchase_orders property will generate an Accounts Payable Invoice from the specified Purchase Order(s). */ public InvoiceResponse create(InvoiceEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/invoices"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InvoiceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Invoice object with the given id. */ public Invoice retrieve(String id) { - return retrieve(id, InvoicesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Invoice object with the given id. */ public Invoice retrieve(String id, InvoicesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Invoice object with the given id. */ public Invoice retrieve(String id, InvoicesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/invoices") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Invoice.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Updates an Invoice object with the given id. */ public InvoiceResponse partialUpdate(String id, PatchedInvoiceEndpointRequest request) { - return partialUpdate(id, request, null); + return this.rawClient.partialUpdate(id, request).body(); } /** @@ -298,58 +104,14 @@ public InvoiceResponse partialUpdate(String id, PatchedInvoiceEndpointRequest re */ public InvoiceResponse partialUpdate( String id, PatchedInvoiceEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/invoices") - .addPathSegment(id); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InvoiceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.partialUpdate(id, request, requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList() { - return lineItemsRemoteFieldClassesList( - InvoicesLineItemsRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.lineItemsRemoteFieldClassesList().body(); } /** @@ -357,7 +119,7 @@ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList() { */ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList( InvoicesLineItemsRemoteFieldClassesListRequest request) { - return lineItemsRemoteFieldClassesList(request, null); + return this.rawClient.lineItemsRemoteFieldClassesList(request).body(); } /** @@ -365,155 +127,51 @@ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList( */ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList( InvoicesLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/invoices/line-items/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .lineItemsRemoteFieldClassesList(request, requestOptions) + .body(); } /** * Returns metadata for Invoice PATCHs. */ public MetaResponse metaPatchRetrieve(String id) { - return metaPatchRetrieve(id, null); + return this.rawClient.metaPatchRetrieve(id).body(); } /** * Returns metadata for Invoice PATCHs. */ public MetaResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/invoices/meta/patch") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPatchRetrieve(id, requestOptions).body(); } /** * Returns metadata for Invoice POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Invoice POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/invoices/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - InvoicesRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(InvoicesRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -521,56 +179,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(InvoicesRemoteFieldC */ public PaginatedRemoteFieldClassList remoteFieldClassesList( InvoicesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/invoices/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/invoices/RawInvoicesClient.java b/src/main/java/com/merge/api/resources/accounting/invoices/RawInvoicesClient.java new file mode 100644 index 000000000..38f64442c --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/invoices/RawInvoicesClient.java @@ -0,0 +1,668 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.invoices; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.invoices.requests.InvoiceEndpointRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesLineItemsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesListRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.invoices.requests.InvoicesRetrieveRequest; +import com.merge.api.resources.accounting.invoices.requests.PatchedInvoiceEndpointRequest; +import com.merge.api.resources.accounting.types.Invoice; +import com.merge.api.resources.accounting.types.InvoiceResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedInvoiceList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawInvoicesClient { + protected final ClientOptions clientOptions; + + public RawInvoicesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Invoice objects. + */ + public MergeApiHttpResponse list() { + return list(InvoicesListRequest.builder().build()); + } + + /** + * Returns a list of Invoice objects. + */ + public MergeApiHttpResponse list(InvoicesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Invoice objects. + */ + public MergeApiHttpResponse list(InvoicesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getContactId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "contact_id", request.getContactId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIssueDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "issue_date_after", + request.getIssueDateAfter().get().toString(), + false); + } + if (request.getIssueDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "issue_date_before", + request.getIssueDateBefore().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getNumber().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "number", request.getNumber().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "type", request.getType().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedInvoiceList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Invoice object with the given values. + * Including a PurchaseOrder id in the purchase_orders property will generate an Accounts Payable Invoice from the specified Purchase Order(s). + */ + public MergeApiHttpResponse create(InvoiceEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Invoice object with the given values. + * Including a PurchaseOrder id in the purchase_orders property will generate an Accounts Payable Invoice from the specified Purchase Order(s). + */ + public MergeApiHttpResponse create(InvoiceEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InvoiceResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Invoice object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, InvoicesRetrieveRequest.builder().build()); + } + + /** + * Returns an Invoice object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, InvoicesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Invoice object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, InvoicesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Invoice.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Updates an Invoice object with the given id. + */ + public MergeApiHttpResponse partialUpdate(String id, PatchedInvoiceEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates an Invoice object with the given id. + */ + public MergeApiHttpResponse partialUpdate( + String id, PatchedInvoiceEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), InvoiceResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse lineItemsRemoteFieldClassesList() { + return lineItemsRemoteFieldClassesList( + InvoicesLineItemsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse lineItemsRemoteFieldClassesList( + InvoicesLineItemsRemoteFieldClassesListRequest request) { + return lineItemsRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse lineItemsRemoteFieldClassesList( + InvoicesLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices/line-items/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Invoice PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Invoice PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Invoice POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Invoice POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + InvoicesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + InvoicesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + InvoicesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/invoices/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/invoices/requests/InvoicesListRequest.java b/src/main/java/com/merge/api/resources/accounting/invoices/requests/InvoicesListRequest.java index ee786508a..a4a544a94 100644 --- a/src/main/java/com/merge/api/resources/accounting/invoices/requests/InvoicesListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/invoices/requests/InvoicesListRequest.java @@ -12,11 +12,13 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.invoices.types.InvoicesListRequestExpand; +import com.merge.api.resources.accounting.invoices.types.InvoicesListRequestExpandItem; import com.merge.api.resources.accounting.invoices.types.InvoicesListRequestStatus; import com.merge.api.resources.accounting.invoices.types.InvoicesListRequestType; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -24,6 +26,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = InvoicesListRequest.Builder.class) public final class InvoicesListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional contactId; @@ -34,8 +38,6 @@ public final class InvoicesListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -69,12 +71,12 @@ public final class InvoicesListRequest { private final Map additionalProperties; private InvoicesListRequest( + Optional> expand, Optional companyId, Optional contactId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -91,12 +93,12 @@ private InvoicesListRequest( Optional status, Optional type, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.contactId = contactId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -115,6 +117,14 @@ private InvoicesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return invoices for this company. */ @@ -155,14 +165,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -307,12 +309,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(InvoicesListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && contactId.equals(other.contactId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -333,12 +335,12 @@ private boolean equalTo(InvoicesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.contactId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -367,6 +369,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional contactId = Optional.empty(); @@ -377,8 +381,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -415,12 +417,12 @@ public static final class Builder { private Builder() {} public Builder from(InvoicesListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); contactId(other.getContactId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -439,6 +441,22 @@ public Builder from(InvoicesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(InvoicesListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -494,17 +512,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(InvoicesListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -672,12 +679,12 @@ public Builder type(InvoicesListRequestType type) { public InvoicesListRequest build() { return new InvoicesListRequest( + expand, companyId, contactId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/accounting/invoices/requests/InvoicesRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/invoices/requests/InvoicesRetrieveRequest.java index eb21d1c80..a234921cf 100644 --- a/src/main/java/com/merge/api/resources/accounting/invoices/requests/InvoicesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/invoices/requests/InvoicesRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.invoices.types.InvoicesRetrieveRequestExpand; +import com.merge.api.resources.accounting.invoices.types.InvoicesRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,12 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = InvoicesRetrieveRequest.Builder.class) public final class InvoicesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -34,15 +38,17 @@ public final class InvoicesRetrieveRequest { private final Map additionalProperties; private InvoicesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -52,7 +58,7 @@ private InvoicesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -72,6 +78,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -103,6 +117,7 @@ private boolean equalTo(InvoicesRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @@ -110,7 +125,12 @@ private boolean equalTo(InvoicesRetrieveRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.expand, this.includeRemoteData, this.includeRemoteFields, this.remoteFields, this.showEnumOrigins); + this.expand, + this.includeRemoteData, + this.includeRemoteFields, + this.includeShellData, + this.remoteFields, + this.showEnumOrigins); } @java.lang.Override @@ -124,12 +144,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -143,22 +165,28 @@ public Builder from(InvoicesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(InvoicesRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(InvoicesRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -181,6 +209,17 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -208,6 +247,7 @@ public InvoicesRetrieveRequest build() { expand, includeRemoteData, includeRemoteFields, + includeShellData, remoteFields, showEnumOrigins, additionalProperties); diff --git a/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesListRequestExpand.java deleted file mode 100644 index 45eb70f22..000000000 --- a/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesListRequestExpand.java +++ /dev/null @@ -1,5778 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.invoices.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum InvoicesListRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - APPLIED_CREDIT_NOTES("applied_credit_notes"), - - APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD("applied_credit_notes,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS("applied_credit_notes,applied_vendor_credits"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY("applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT("applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE("applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_COMPANY("applied_credit_notes,company"), - - APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD("applied_credit_notes,company,accounting_period"), - - APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE("applied_credit_notes,company,employee"), - - APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("applied_credit_notes,company,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_CONTACT("applied_credit_notes,contact"), - - APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD("applied_credit_notes,contact,accounting_period"), - - APPLIED_CREDIT_NOTES_CONTACT_COMPANY("applied_credit_notes,contact,company"), - - APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD("applied_credit_notes,contact,company,accounting_period"), - - APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE("applied_credit_notes,contact,company,employee"), - - APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE("applied_credit_notes,contact,employee"), - - APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_EMPLOYEE("applied_credit_notes,employee"), - - APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD("applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS("applied_payments"), - - APPLIED_PAYMENTS_ACCOUNTING_PERIOD("applied_payments,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES("applied_payments,applied_credit_notes"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD("applied_payments,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY("applied_payments,applied_credit_notes,company"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE("applied_payments,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT("applied_payments,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY("applied_payments,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE("applied_payments,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE("applied_payments,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS("applied_payments,applied_vendor_credits"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY("applied_payments,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT("applied_payments,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY("applied_payments,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE("applied_payments,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_COMPANY("applied_payments,company"), - - APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("applied_payments,company,accounting_period"), - - APPLIED_PAYMENTS_COMPANY_EMPLOYEE("applied_payments,company,employee"), - - APPLIED_PAYMENTS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("applied_payments,company,employee,accounting_period"), - - APPLIED_PAYMENTS_CONTACT("applied_payments,contact"), - - APPLIED_PAYMENTS_CONTACT_ACCOUNTING_PERIOD("applied_payments,contact,accounting_period"), - - APPLIED_PAYMENTS_CONTACT_COMPANY("applied_payments,contact,company"), - - APPLIED_PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD("applied_payments,contact,company,accounting_period"), - - APPLIED_PAYMENTS_CONTACT_COMPANY_EMPLOYEE("applied_payments,contact,company,employee"), - - APPLIED_PAYMENTS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_CONTACT_EMPLOYEE("applied_payments,contact,employee"), - - APPLIED_PAYMENTS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("applied_payments,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_EMPLOYEE("applied_payments,employee"), - - APPLIED_PAYMENTS_EMPLOYEE_ACCOUNTING_PERIOD("applied_payments,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS("applied_payments,line_items"), - - APPLIED_PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("applied_payments,line_items,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES("applied_payments,line_items,applied_credit_notes"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,line_items,applied_credit_notes,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,line_items,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,line_items,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS("applied_payments,line_items,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY("applied_payments,line_items,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("applied_payments,line_items,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE("applied_payments,line_items,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT("applied_payments,line_items,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("applied_payments,line_items,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("applied_payments,line_items,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE("applied_payments,line_items,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE("applied_payments,line_items,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_EMPLOYEE("applied_payments,line_items,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_EMPLOYEE_ACCOUNTING_PERIOD("applied_payments,line_items,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS("applied_payments,line_items,purchase_orders"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "applied_payments,line_items,purchase_orders,applied_credit_notes"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,line_items,purchase_orders,applied_credit_notes,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,purchase_orders,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY("applied_payments,line_items,purchase_orders,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT("applied_payments,line_items,purchase_orders,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY( - "applied_payments,line_items,purchase_orders,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "applied_payments,line_items,purchase_orders,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE("applied_payments,line_items,purchase_orders,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES("applied_payments,line_items,tracking_categories"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES( - "applied_payments,line_items,tracking_categories,applied_credit_notes"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,line_items,tracking_categories,applied_credit_notes,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,tracking_categories,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("applied_payments,line_items,tracking_categories,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("applied_payments,line_items,tracking_categories,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE( - "applied_payments,line_items,tracking_categories,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS( - "applied_payments,line_items,tracking_categories,purchase_orders"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT( - "applied_payments,line_items,tracking_categories,purchase_orders,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS("applied_payments,purchase_orders"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_ACCOUNTING_PERIOD("applied_payments,purchase_orders,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES("applied_payments,purchase_orders,applied_credit_notes"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,purchase_orders,applied_credit_notes,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,purchase_orders,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,purchase_orders,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS("applied_payments,purchase_orders,applied_vendor_credits"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,purchase_orders,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,purchase_orders,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,purchase_orders,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,purchase_orders,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,purchase_orders,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY("applied_payments,purchase_orders,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE("applied_payments,purchase_orders,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT("applied_payments,purchase_orders,contact"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,contact,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY("applied_payments,purchase_orders,contact,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,contact,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,contact,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE("applied_payments,purchase_orders,contact,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_EMPLOYEE("applied_payments,purchase_orders,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES("applied_payments,tracking_categories"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("applied_payments,tracking_categories,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES( - "applied_payments,tracking_categories,applied_credit_notes"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,tracking_categories,applied_credit_notes,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,tracking_categories,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,tracking_categories,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS( - "applied_payments,tracking_categories,applied_vendor_credits"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,tracking_categories,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,tracking_categories,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,tracking_categories,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,tracking_categories,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("applied_payments,tracking_categories,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE("applied_payments,tracking_categories,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT("applied_payments,tracking_categories,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY("applied_payments,tracking_categories,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE("applied_payments,tracking_categories,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE("applied_payments,tracking_categories,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS("applied_payments,tracking_categories,purchase_orders"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY( - "applied_payments,tracking_categories,purchase_orders,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT( - "applied_payments,tracking_categories,purchase_orders,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "applied_payments,tracking_categories,purchase_orders,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,employee,accounting_period"), - - APPLIED_VENDOR_CREDITS("applied_vendor_credits"), - - APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD("applied_vendor_credits,accounting_period"), - - APPLIED_VENDOR_CREDITS_COMPANY("applied_vendor_credits,company"), - - APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD("applied_vendor_credits,company,accounting_period"), - - APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE("applied_vendor_credits,company,employee"), - - APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_VENDOR_CREDITS_CONTACT("applied_vendor_credits,contact"), - - APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD("applied_vendor_credits,contact,accounting_period"), - - APPLIED_VENDOR_CREDITS_CONTACT_COMPANY("applied_vendor_credits,contact,company"), - - APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE("applied_vendor_credits,contact,company,employee"), - - APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE("applied_vendor_credits,contact,employee"), - - APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_VENDOR_CREDITS_EMPLOYEE("applied_vendor_credits,employee"), - - APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD("applied_vendor_credits,employee,accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - COMPANY_EMPLOYEE("company,employee"), - - COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("company,employee,accounting_period"), - - CONTACT("contact"), - - CONTACT_ACCOUNTING_PERIOD("contact,accounting_period"), - - CONTACT_COMPANY("contact,company"), - - CONTACT_COMPANY_ACCOUNTING_PERIOD("contact,company,accounting_period"), - - CONTACT_COMPANY_EMPLOYEE("contact,company,employee"), - - CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("contact,company,employee,accounting_period"), - - CONTACT_EMPLOYEE("contact,employee"), - - CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("contact,employee,accounting_period"), - - EMPLOYEE("employee"), - - EMPLOYEE_ACCOUNTING_PERIOD("employee,accounting_period"), - - LINE_ITEMS("line_items"), - - LINE_ITEMS_ACCOUNTING_PERIOD("line_items,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES("line_items,applied_credit_notes"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD("line_items,applied_credit_notes,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS("line_items,applied_credit_notes,applied_vendor_credits"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,applied_credit_notes,applied_vendor_credits,company"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,applied_credit_notes,applied_vendor_credits,company,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,applied_credit_notes,applied_vendor_credits,contact"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,applied_credit_notes,applied_vendor_credits,contact,company"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,applied_credit_notes,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,applied_credit_notes,applied_vendor_credits,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY("line_items,applied_credit_notes,company"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,company,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE("line_items,applied_credit_notes,company,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT("line_items,applied_credit_notes,contact"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,contact,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY("line_items,applied_credit_notes,contact,company"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,contact,company,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "line_items,applied_credit_notes,contact,company,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,contact,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE("line_items,applied_credit_notes,contact,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,contact,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE("line_items,applied_credit_notes,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,employee,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS("line_items,applied_vendor_credits"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD("line_items,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY("line_items,applied_vendor_credits,company"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE("line_items,applied_vendor_credits,company,employee"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT("line_items,applied_vendor_credits,contact"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY("line_items,applied_vendor_credits,contact,company"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE("line_items,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE("line_items,applied_vendor_credits,employee"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_COMPANY("line_items,company"), - - LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("line_items,company,accounting_period"), - - LINE_ITEMS_COMPANY_EMPLOYEE("line_items,company,employee"), - - LINE_ITEMS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("line_items,company,employee,accounting_period"), - - LINE_ITEMS_CONTACT("line_items,contact"), - - LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("line_items,contact,accounting_period"), - - LINE_ITEMS_CONTACT_COMPANY("line_items,contact,company"), - - LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD("line_items,contact,company,accounting_period"), - - LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE("line_items,contact,company,employee"), - - LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("line_items,contact,company,employee,accounting_period"), - - LINE_ITEMS_CONTACT_EMPLOYEE("line_items,contact,employee"), - - LINE_ITEMS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("line_items,contact,employee,accounting_period"), - - LINE_ITEMS_EMPLOYEE("line_items,employee"), - - LINE_ITEMS_EMPLOYEE_ACCOUNTING_PERIOD("line_items,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS("line_items,purchase_orders"), - - LINE_ITEMS_PURCHASE_ORDERS_ACCOUNTING_PERIOD("line_items,purchase_orders,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES("line_items,purchase_orders,applied_credit_notes"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY("line_items,purchase_orders,applied_credit_notes,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT("line_items,purchase_orders,applied_credit_notes,contact"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,contact,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "line_items,purchase_orders,applied_credit_notes,contact,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,contact,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,contact,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS("line_items,purchase_orders,applied_vendor_credits"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,purchase_orders,applied_vendor_credits,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_vendor_credits,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,purchase_orders,applied_vendor_credits,contact"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,purchase_orders,applied_vendor_credits,contact,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,purchase_orders,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,purchase_orders,applied_vendor_credits,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_COMPANY("line_items,purchase_orders,company"), - - LINE_ITEMS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD("line_items,purchase_orders,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE("line_items,purchase_orders,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT("line_items,purchase_orders,contact"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD("line_items,purchase_orders,contact,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY("line_items,purchase_orders,contact,company"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,contact,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE("line_items,purchase_orders,contact,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,contact,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE("line_items,purchase_orders,contact,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,contact,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE("line_items,purchase_orders,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD("line_items,purchase_orders,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES("line_items,tracking_categories"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("line_items,tracking_categories,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES("line_items,tracking_categories,applied_credit_notes"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "line_items,tracking_categories,applied_credit_notes,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "line_items,tracking_categories,applied_credit_notes,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "line_items,tracking_categories,applied_credit_notes,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS("line_items,tracking_categories,applied_vendor_credits"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,tracking_categories,applied_vendor_credits,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_vendor_credits,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,tracking_categories,applied_vendor_credits,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,tracking_categories,applied_vendor_credits,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,tracking_categories,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,tracking_categories,applied_vendor_credits,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("line_items,tracking_categories,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE("line_items,tracking_categories,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("line_items,tracking_categories,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY("line_items,tracking_categories,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE("line_items,tracking_categories,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE("line_items,tracking_categories,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE("line_items,tracking_categories,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS("line_items,tracking_categories,purchase_orders"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "line_items,tracking_categories,purchase_orders,applied_credit_notes"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY("line_items,tracking_categories,purchase_orders,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT("line_items,tracking_categories,purchase_orders,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "line_items,tracking_categories,purchase_orders,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE("line_items,tracking_categories,purchase_orders,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,employee,accounting_period"), - - PAYMENTS("payments"), - - PAYMENTS_ACCOUNTING_PERIOD("payments,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES("payments,applied_credit_notes"), - - PAYMENTS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD("payments,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS("payments,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY("payments,applied_credit_notes,company"), - - PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD("payments,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE("payments,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT("payments,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD("payments,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY("payments,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE("payments,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE("payments,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE("payments,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS("payments,applied_payments"), - - PAYMENTS_APPLIED_PAYMENTS_ACCOUNTING_PERIOD("payments,applied_payments,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES("payments,applied_payments,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY("payments,applied_payments,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT("payments,applied_payments,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE("payments,applied_payments,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS("payments,applied_payments,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY("payments,applied_payments,company"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,applied_payments,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY_EMPLOYEE("payments,applied_payments,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT("payments,applied_payments,contact"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_ACCOUNTING_PERIOD("payments,applied_payments,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY("payments,applied_payments,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY_EMPLOYEE("payments,applied_payments,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_EMPLOYEE("payments,applied_payments,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_EMPLOYEE("payments,applied_payments,employee"), - - PAYMENTS_APPLIED_PAYMENTS_EMPLOYEE_ACCOUNTING_PERIOD("payments,applied_payments,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS("payments,applied_payments,line_items"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("payments,applied_payments,line_items,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES( - "payments,applied_payments,line_items,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,line_items,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,line_items,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,line_items,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY("payments,applied_payments,line_items,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE("payments,applied_payments,line_items,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT("payments,applied_payments,line_items,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("payments,applied_payments,line_items,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE("payments,applied_payments,line_items,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_EMPLOYEE("payments,applied_payments,line_items,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS("payments,applied_payments,line_items,purchase_orders"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY( - "payments,applied_payments,line_items,purchase_orders,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT( - "payments,applied_payments,line_items,purchase_orders,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,applied_payments,line_items,purchase_orders,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES( - "payments,applied_payments,line_items,tracking_categories"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY( - "payments,applied_payments,line_items,tracking_categories,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT( - "payments,applied_payments,line_items,tracking_categories,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS( - "payments,applied_payments,line_items,tracking_categories,purchase_orders"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS("payments,applied_payments,purchase_orders"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,applied_payments,purchase_orders,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,purchase_orders,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY("payments,applied_payments,purchase_orders,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT("payments,applied_payments,purchase_orders,contact"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,applied_payments,purchase_orders,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,applied_payments,purchase_orders,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_EMPLOYEE("payments,applied_payments,purchase_orders,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES("payments,applied_payments,tracking_categories"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES( - "payments,applied_payments,tracking_categories,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,tracking_categories,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,tracking_categories,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,tracking_categories,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,applied_payments,tracking_categories,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT("payments,applied_payments,tracking_categories,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE("payments,applied_payments,tracking_categories,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS( - "payments,applied_payments,tracking_categories,purchase_orders"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT( - "payments,applied_payments,tracking_categories,purchase_orders,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,employee,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS("payments,applied_vendor_credits"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD("payments,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY("payments,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE("payments,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT("payments,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY("payments,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE("payments,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE("payments,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_COMPANY("payments,company"), - - PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,company,accounting_period"), - - PAYMENTS_COMPANY_EMPLOYEE("payments,company,employee"), - - PAYMENTS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("payments,company,employee,accounting_period"), - - PAYMENTS_CONTACT("payments,contact"), - - PAYMENTS_CONTACT_ACCOUNTING_PERIOD("payments,contact,accounting_period"), - - PAYMENTS_CONTACT_COMPANY("payments,contact,company"), - - PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD("payments,contact,company,accounting_period"), - - PAYMENTS_CONTACT_COMPANY_EMPLOYEE("payments,contact,company,employee"), - - PAYMENTS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("payments,contact,company,employee,accounting_period"), - - PAYMENTS_CONTACT_EMPLOYEE("payments,contact,employee"), - - PAYMENTS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("payments,contact,employee,accounting_period"), - - PAYMENTS_EMPLOYEE("payments,employee"), - - PAYMENTS_EMPLOYEE_ACCOUNTING_PERIOD("payments,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS("payments,line_items"), - - PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("payments,line_items,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES("payments,line_items,applied_credit_notes"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,line_items,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY("payments,line_items,applied_credit_notes,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,line_items,applied_credit_notes,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT("payments,line_items,applied_credit_notes,contact"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,line_items,applied_credit_notes,contact,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,applied_credit_notes,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,line_items,applied_credit_notes,contact,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE("payments,line_items,applied_credit_notes,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS("payments,line_items,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY("payments,line_items,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT("payments,line_items,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE("payments,line_items,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_COMPANY("payments,line_items,company"), - - PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("payments,line_items,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE("payments,line_items,company,employee"), - - PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("payments,line_items,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT("payments,line_items,contact"), - - PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("payments,line_items,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("payments,line_items,contact,company"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD("payments,line_items,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE("payments,line_items,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE("payments,line_items,contact,employee"), - - PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("payments,line_items,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_EMPLOYEE("payments,line_items,employee"), - - PAYMENTS_LINE_ITEMS_EMPLOYEE_ACCOUNTING_PERIOD("payments,line_items,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS("payments,line_items,purchase_orders"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_ACCOUNTING_PERIOD("payments,line_items,purchase_orders,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,line_items,purchase_orders,applied_credit_notes"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,line_items,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,line_items,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,line_items,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,line_items,purchase_orders,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY("payments,line_items,purchase_orders,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE("payments,line_items,purchase_orders,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT("payments,line_items,purchase_orders,contact"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY("payments,line_items,purchase_orders,contact,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE("payments,line_items,purchase_orders,contact,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE("payments,line_items,purchase_orders,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES("payments,line_items,tracking_categories"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES( - "payments,line_items,tracking_categories,applied_credit_notes"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "payments,line_items,tracking_categories,applied_credit_notes,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "payments,line_items,tracking_categories,applied_credit_notes,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,line_items,tracking_categories,applied_credit_notes,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS( - "payments,line_items,tracking_categories,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,tracking_categories,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,tracking_categories,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,tracking_categories,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("payments,line_items,tracking_categories,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("payments,line_items,tracking_categories,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY("payments,line_items,tracking_categories,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE("payments,line_items,tracking_categories,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS("payments,line_items,tracking_categories,purchase_orders"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT( - "payments,line_items,tracking_categories,purchase_orders,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS("payments,purchase_orders"), - - PAYMENTS_PURCHASE_ORDERS_ACCOUNTING_PERIOD("payments,purchase_orders,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES("payments,purchase_orders,applied_credit_notes"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY("payments,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT("payments,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE("payments,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS("payments,purchase_orders,applied_vendor_credits"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY("payments,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT("payments,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_COMPANY("payments,purchase_orders,company"), - - PAYMENTS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD("payments,purchase_orders,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE("payments,purchase_orders,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT("payments,purchase_orders,contact"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD("payments,purchase_orders,contact,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY("payments,purchase_orders,contact,company"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE("payments,purchase_orders,contact,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE("payments,purchase_orders,contact,employee"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_EMPLOYEE("payments,purchase_orders,employee"), - - PAYMENTS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD("payments,purchase_orders,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES("payments,tracking_categories"), - - PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("payments,tracking_categories,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES("payments,tracking_categories,applied_credit_notes"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "payments,tracking_categories,applied_credit_notes,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "payments,tracking_categories,applied_credit_notes,contact"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,tracking_categories,applied_credit_notes,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS("payments,tracking_categories,applied_vendor_credits"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,tracking_categories,applied_vendor_credits,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_vendor_credits,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,tracking_categories,applied_vendor_credits,contact"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,tracking_categories,applied_vendor_credits,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,tracking_categories,applied_vendor_credits,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,tracking_categories,applied_vendor_credits,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,tracking_categories,company"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("payments,tracking_categories,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE("payments,tracking_categories,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT("payments,tracking_categories,contact"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("payments,tracking_categories,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY("payments,tracking_categories,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE("payments,tracking_categories,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE("payments,tracking_categories,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE("payments,tracking_categories,employee"), - - PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD("payments,tracking_categories,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS("payments,tracking_categories,purchase_orders"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,tracking_categories,purchase_orders,applied_credit_notes"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,tracking_categories,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,tracking_categories,purchase_orders,applied_vendor_credits"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY("payments,tracking_categories,purchase_orders,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT("payments,tracking_categories,purchase_orders,contact"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,tracking_categories,purchase_orders,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,tracking_categories,purchase_orders,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE("payments,tracking_categories,purchase_orders,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,employee,accounting_period"), - - PURCHASE_ORDERS("purchase_orders"), - - PURCHASE_ORDERS_ACCOUNTING_PERIOD("purchase_orders,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES("purchase_orders,applied_credit_notes"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD("purchase_orders,applied_credit_notes,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY("purchase_orders,applied_credit_notes,company"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE("purchase_orders,applied_credit_notes,company,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT("purchase_orders,applied_credit_notes,contact"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,contact,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY("purchase_orders,applied_credit_notes,contact,company"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "purchase_orders,applied_credit_notes,contact,company,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE("purchase_orders,applied_credit_notes,contact,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE("purchase_orders,applied_credit_notes,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS("purchase_orders,applied_vendor_credits"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY("purchase_orders,applied_vendor_credits,company"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE("purchase_orders,applied_vendor_credits,company,employee"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT("purchase_orders,applied_vendor_credits,contact"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY("purchase_orders,applied_vendor_credits,contact,company"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "purchase_orders,applied_vendor_credits,contact,company,employee"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE("purchase_orders,applied_vendor_credits,contact,employee"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE("purchase_orders,applied_vendor_credits,employee"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PURCHASE_ORDERS_COMPANY("purchase_orders,company"), - - PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD("purchase_orders,company,accounting_period"), - - PURCHASE_ORDERS_COMPANY_EMPLOYEE("purchase_orders,company,employee"), - - PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("purchase_orders,company,employee,accounting_period"), - - PURCHASE_ORDERS_CONTACT("purchase_orders,contact"), - - PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD("purchase_orders,contact,accounting_period"), - - PURCHASE_ORDERS_CONTACT_COMPANY("purchase_orders,contact,company"), - - PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD("purchase_orders,contact,company,accounting_period"), - - PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE("purchase_orders,contact,company,employee"), - - PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,contact,company,employee,accounting_period"), - - PURCHASE_ORDERS_CONTACT_EMPLOYEE("purchase_orders,contact,employee"), - - PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("purchase_orders,contact,employee,accounting_period"), - - PURCHASE_ORDERS_EMPLOYEE("purchase_orders,employee"), - - PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD("purchase_orders,employee,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES("tracking_categories,applied_credit_notes"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "tracking_categories,applied_credit_notes,applied_vendor_credits"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY("tracking_categories,applied_credit_notes,company"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "tracking_categories,applied_credit_notes,company,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT("tracking_categories,applied_credit_notes,contact"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,contact,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "tracking_categories,applied_credit_notes,contact,company"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,applied_credit_notes,contact,company,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "tracking_categories,applied_credit_notes,contact,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE("tracking_categories,applied_credit_notes,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS("tracking_categories,applied_vendor_credits"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY("tracking_categories,applied_vendor_credits,company"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "tracking_categories,applied_vendor_credits,company,employee"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT("tracking_categories,applied_vendor_credits,contact"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,contact,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "tracking_categories,applied_vendor_credits,contact,company"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,applied_vendor_credits,contact,company,employee"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "tracking_categories,applied_vendor_credits,contact,employee"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE("tracking_categories,applied_vendor_credits,employee"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,employee,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_COMPANY_EMPLOYEE("tracking_categories,company,employee"), - - TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,company,employee,accounting_period"), - - TRACKING_CATEGORIES_CONTACT("tracking_categories,contact"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("tracking_categories,contact,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY("tracking_categories,contact,company"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,contact,company,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE("tracking_categories,contact,company,employee"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_EMPLOYEE("tracking_categories,contact,employee"), - - TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_EMPLOYEE("tracking_categories,employee"), - - TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS("tracking_categories,purchase_orders"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD("tracking_categories,purchase_orders,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "tracking_categories,purchase_orders,applied_credit_notes"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "tracking_categories,purchase_orders,applied_credit_notes,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "tracking_categories,purchase_orders,applied_credit_notes,contact"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "tracking_categories,purchase_orders,applied_vendor_credits"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "tracking_categories,purchase_orders,applied_vendor_credits,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY("tracking_categories,purchase_orders,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE("tracking_categories,purchase_orders,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT("tracking_categories,purchase_orders,contact"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,contact,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY("tracking_categories,purchase_orders,contact,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,contact,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,contact,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE("tracking_categories,purchase_orders,contact,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE("tracking_categories,purchase_orders,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,employee,accounting_period"); - - private final String value; - - InvoicesListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesListRequestExpandItem.java new file mode 100644 index 000000000..4f1cda66b --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesListRequestExpandItem.java @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.invoices.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum InvoicesListRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + APPLIED_CREDIT_NOTES("applied_credit_notes"), + + APPLIED_PAYMENTS("applied_payments"), + + APPLIED_VENDOR_CREDITS("applied_vendor_credits"), + + COMPANY("company"), + + CONTACT("contact"), + + EMPLOYEE("employee"), + + LINE_ITEMS("line_items"), + + PAYMENT_TERM("payment_term"), + + PAYMENTS("payments"), + + PURCHASE_ORDERS("purchase_orders"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + InvoicesListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesRetrieveRequestExpand.java deleted file mode 100644 index 58f4bde4c..000000000 --- a/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesRetrieveRequestExpand.java +++ /dev/null @@ -1,5778 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.invoices.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum InvoicesRetrieveRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - APPLIED_CREDIT_NOTES("applied_credit_notes"), - - APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD("applied_credit_notes,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS("applied_credit_notes,applied_vendor_credits"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY("applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT("applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE("applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_COMPANY("applied_credit_notes,company"), - - APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD("applied_credit_notes,company,accounting_period"), - - APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE("applied_credit_notes,company,employee"), - - APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("applied_credit_notes,company,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_CONTACT("applied_credit_notes,contact"), - - APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD("applied_credit_notes,contact,accounting_period"), - - APPLIED_CREDIT_NOTES_CONTACT_COMPANY("applied_credit_notes,contact,company"), - - APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD("applied_credit_notes,contact,company,accounting_period"), - - APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE("applied_credit_notes,contact,company,employee"), - - APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE("applied_credit_notes,contact,employee"), - - APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_CREDIT_NOTES_EMPLOYEE("applied_credit_notes,employee"), - - APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD("applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS("applied_payments"), - - APPLIED_PAYMENTS_ACCOUNTING_PERIOD("applied_payments,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES("applied_payments,applied_credit_notes"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD("applied_payments,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY("applied_payments,applied_credit_notes,company"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE("applied_payments,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT("applied_payments,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY("applied_payments,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE("applied_payments,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE("applied_payments,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS("applied_payments,applied_vendor_credits"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY("applied_payments,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT("applied_payments,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY("applied_payments,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE("applied_payments,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_COMPANY("applied_payments,company"), - - APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("applied_payments,company,accounting_period"), - - APPLIED_PAYMENTS_COMPANY_EMPLOYEE("applied_payments,company,employee"), - - APPLIED_PAYMENTS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("applied_payments,company,employee,accounting_period"), - - APPLIED_PAYMENTS_CONTACT("applied_payments,contact"), - - APPLIED_PAYMENTS_CONTACT_ACCOUNTING_PERIOD("applied_payments,contact,accounting_period"), - - APPLIED_PAYMENTS_CONTACT_COMPANY("applied_payments,contact,company"), - - APPLIED_PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD("applied_payments,contact,company,accounting_period"), - - APPLIED_PAYMENTS_CONTACT_COMPANY_EMPLOYEE("applied_payments,contact,company,employee"), - - APPLIED_PAYMENTS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_CONTACT_EMPLOYEE("applied_payments,contact,employee"), - - APPLIED_PAYMENTS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("applied_payments,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_EMPLOYEE("applied_payments,employee"), - - APPLIED_PAYMENTS_EMPLOYEE_ACCOUNTING_PERIOD("applied_payments,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS("applied_payments,line_items"), - - APPLIED_PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("applied_payments,line_items,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES("applied_payments,line_items,applied_credit_notes"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,line_items,applied_credit_notes,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,line_items,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,line_items,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,line_items,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS("applied_payments,line_items,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY("applied_payments,line_items,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("applied_payments,line_items,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE("applied_payments,line_items,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT("applied_payments,line_items,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("applied_payments,line_items,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("applied_payments,line_items,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE("applied_payments,line_items,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE("applied_payments,line_items,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_EMPLOYEE("applied_payments,line_items,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_EMPLOYEE_ACCOUNTING_PERIOD("applied_payments,line_items,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS("applied_payments,line_items,purchase_orders"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "applied_payments,line_items,purchase_orders,applied_credit_notes"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,line_items,purchase_orders,applied_credit_notes,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,purchase_orders,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY("applied_payments,line_items,purchase_orders,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT("applied_payments,line_items,purchase_orders,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY( - "applied_payments,line_items,purchase_orders,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,purchase_orders,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "applied_payments,line_items,purchase_orders,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE("applied_payments,line_items,purchase_orders,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,purchase_orders,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES("applied_payments,line_items,tracking_categories"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES( - "applied_payments,line_items,tracking_categories,applied_credit_notes"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,line_items,tracking_categories,applied_credit_notes,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,tracking_categories,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("applied_payments,line_items,tracking_categories,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("applied_payments,line_items,tracking_categories,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE( - "applied_payments,line_items,tracking_categories,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS( - "applied_payments,line_items,tracking_categories,purchase_orders"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT( - "applied_payments,line_items,tracking_categories,purchase_orders,contact"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,company"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,company,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,company,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE( - "applied_payments,line_items,tracking_categories,purchase_orders,employee"), - - APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,line_items,tracking_categories,purchase_orders,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS("applied_payments,purchase_orders"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_ACCOUNTING_PERIOD("applied_payments,purchase_orders,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES("applied_payments,purchase_orders,applied_credit_notes"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,purchase_orders,applied_credit_notes,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,purchase_orders,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,purchase_orders,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,purchase_orders,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS("applied_payments,purchase_orders,applied_vendor_credits"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,purchase_orders,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,purchase_orders,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,purchase_orders,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,purchase_orders,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,purchase_orders,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY("applied_payments,purchase_orders,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE("applied_payments,purchase_orders,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT("applied_payments,purchase_orders,contact"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,contact,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY("applied_payments,purchase_orders,contact,company"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,contact,company,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,purchase_orders,contact,company,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE("applied_payments,purchase_orders,contact,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_EMPLOYEE("applied_payments,purchase_orders,employee"), - - APPLIED_PAYMENTS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,purchase_orders,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES("applied_payments,tracking_categories"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("applied_payments,tracking_categories,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES( - "applied_payments,tracking_categories,applied_credit_notes"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,tracking_categories,applied_credit_notes,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,tracking_categories,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,tracking_categories,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,tracking_categories,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS( - "applied_payments,tracking_categories,applied_vendor_credits"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,tracking_categories,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,tracking_categories,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,tracking_categories,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,tracking_categories,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("applied_payments,tracking_categories,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE("applied_payments,tracking_categories,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT("applied_payments,tracking_categories,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY("applied_payments,tracking_categories,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE("applied_payments,tracking_categories,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE("applied_payments,tracking_categories,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS("applied_payments,tracking_categories,purchase_orders"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY( - "applied_payments,tracking_categories,purchase_orders,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT( - "applied_payments,tracking_categories,purchase_orders,contact"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,contact,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "applied_payments,tracking_categories,purchase_orders,contact,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,contact,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,contact,company,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,contact,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE( - "applied_payments,tracking_categories,purchase_orders,employee"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,purchase_orders,employee,accounting_period"), - - APPLIED_VENDOR_CREDITS("applied_vendor_credits"), - - APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD("applied_vendor_credits,accounting_period"), - - APPLIED_VENDOR_CREDITS_COMPANY("applied_vendor_credits,company"), - - APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD("applied_vendor_credits,company,accounting_period"), - - APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE("applied_vendor_credits,company,employee"), - - APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_vendor_credits,company,employee,accounting_period"), - - APPLIED_VENDOR_CREDITS_CONTACT("applied_vendor_credits,contact"), - - APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD("applied_vendor_credits,contact,accounting_period"), - - APPLIED_VENDOR_CREDITS_CONTACT_COMPANY("applied_vendor_credits,contact,company"), - - APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "applied_vendor_credits,contact,company,accounting_period"), - - APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE("applied_vendor_credits,contact,company,employee"), - - APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_vendor_credits,contact,company,employee,accounting_period"), - - APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE("applied_vendor_credits,contact,employee"), - - APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "applied_vendor_credits,contact,employee,accounting_period"), - - APPLIED_VENDOR_CREDITS_EMPLOYEE("applied_vendor_credits,employee"), - - APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD("applied_vendor_credits,employee,accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - COMPANY_EMPLOYEE("company,employee"), - - COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("company,employee,accounting_period"), - - CONTACT("contact"), - - CONTACT_ACCOUNTING_PERIOD("contact,accounting_period"), - - CONTACT_COMPANY("contact,company"), - - CONTACT_COMPANY_ACCOUNTING_PERIOD("contact,company,accounting_period"), - - CONTACT_COMPANY_EMPLOYEE("contact,company,employee"), - - CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("contact,company,employee,accounting_period"), - - CONTACT_EMPLOYEE("contact,employee"), - - CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("contact,employee,accounting_period"), - - EMPLOYEE("employee"), - - EMPLOYEE_ACCOUNTING_PERIOD("employee,accounting_period"), - - LINE_ITEMS("line_items"), - - LINE_ITEMS_ACCOUNTING_PERIOD("line_items,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES("line_items,applied_credit_notes"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD("line_items,applied_credit_notes,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS("line_items,applied_credit_notes,applied_vendor_credits"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,applied_credit_notes,applied_vendor_credits,company"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,applied_credit_notes,applied_vendor_credits,company,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,applied_credit_notes,applied_vendor_credits,contact"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,applied_credit_notes,applied_vendor_credits,contact,company"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,applied_credit_notes,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,applied_credit_notes,applied_vendor_credits,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY("line_items,applied_credit_notes,company"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,company,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE("line_items,applied_credit_notes,company,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT("line_items,applied_credit_notes,contact"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,contact,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY("line_items,applied_credit_notes,contact,company"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,contact,company,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "line_items,applied_credit_notes,contact,company,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,contact,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE("line_items,applied_credit_notes,contact,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,contact,employee,accounting_period"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE("line_items,applied_credit_notes,employee"), - - LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_credit_notes,employee,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS("line_items,applied_vendor_credits"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD("line_items,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY("line_items,applied_vendor_credits,company"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE("line_items,applied_vendor_credits,company,employee"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT("line_items,applied_vendor_credits,contact"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY("line_items,applied_vendor_credits,contact,company"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE("line_items,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE("line_items,applied_vendor_credits,employee"), - - LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_COMPANY("line_items,company"), - - LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("line_items,company,accounting_period"), - - LINE_ITEMS_COMPANY_EMPLOYEE("line_items,company,employee"), - - LINE_ITEMS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("line_items,company,employee,accounting_period"), - - LINE_ITEMS_CONTACT("line_items,contact"), - - LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("line_items,contact,accounting_period"), - - LINE_ITEMS_CONTACT_COMPANY("line_items,contact,company"), - - LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD("line_items,contact,company,accounting_period"), - - LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE("line_items,contact,company,employee"), - - LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("line_items,contact,company,employee,accounting_period"), - - LINE_ITEMS_CONTACT_EMPLOYEE("line_items,contact,employee"), - - LINE_ITEMS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("line_items,contact,employee,accounting_period"), - - LINE_ITEMS_EMPLOYEE("line_items,employee"), - - LINE_ITEMS_EMPLOYEE_ACCOUNTING_PERIOD("line_items,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS("line_items,purchase_orders"), - - LINE_ITEMS_PURCHASE_ORDERS_ACCOUNTING_PERIOD("line_items,purchase_orders,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES("line_items,purchase_orders,applied_credit_notes"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY("line_items,purchase_orders,applied_credit_notes,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT("line_items,purchase_orders,applied_credit_notes,contact"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,contact,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "line_items,purchase_orders,applied_credit_notes,contact,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,contact,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,contact,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "line_items,purchase_orders,applied_credit_notes,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_credit_notes,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS("line_items,purchase_orders,applied_vendor_credits"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,purchase_orders,applied_vendor_credits,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_vendor_credits,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,purchase_orders,applied_vendor_credits,contact"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,purchase_orders,applied_vendor_credits,contact,company"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,purchase_orders,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,purchase_orders,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,purchase_orders,applied_vendor_credits,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_COMPANY("line_items,purchase_orders,company"), - - LINE_ITEMS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD("line_items,purchase_orders,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE("line_items,purchase_orders,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT("line_items,purchase_orders,contact"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD("line_items,purchase_orders,contact,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY("line_items,purchase_orders,contact,company"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,purchase_orders,contact,company,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE("line_items,purchase_orders,contact,company,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,contact,company,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE("line_items,purchase_orders,contact,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,purchase_orders,contact,employee,accounting_period"), - - LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE("line_items,purchase_orders,employee"), - - LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD("line_items,purchase_orders,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES("line_items,tracking_categories"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("line_items,tracking_categories,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES("line_items,tracking_categories,applied_credit_notes"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "line_items,tracking_categories,applied_credit_notes,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "line_items,tracking_categories,applied_credit_notes,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "line_items,tracking_categories,applied_credit_notes,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "line_items,tracking_categories,applied_credit_notes,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_credit_notes,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS("line_items,tracking_categories,applied_vendor_credits"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,tracking_categories,applied_vendor_credits,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_vendor_credits,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,tracking_categories,applied_vendor_credits,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,tracking_categories,applied_vendor_credits,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,tracking_categories,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,tracking_categories,applied_vendor_credits,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("line_items,tracking_categories,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE("line_items,tracking_categories,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("line_items,tracking_categories,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY("line_items,tracking_categories,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE("line_items,tracking_categories,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE("line_items,tracking_categories,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE("line_items,tracking_categories,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS("line_items,tracking_categories,purchase_orders"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "line_items,tracking_categories,purchase_orders,applied_credit_notes"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY("line_items,tracking_categories,purchase_orders,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT("line_items,tracking_categories,purchase_orders,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "line_items,tracking_categories,purchase_orders,contact,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,contact,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,contact,company,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "line_items,tracking_categories,purchase_orders,contact,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE("line_items,tracking_categories,purchase_orders,employee"), - - LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "line_items,tracking_categories,purchase_orders,employee,accounting_period"), - - PAYMENTS("payments"), - - PAYMENTS_ACCOUNTING_PERIOD("payments,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES("payments,applied_credit_notes"), - - PAYMENTS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD("payments,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS("payments,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY("payments,applied_credit_notes,company"), - - PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD("payments,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE("payments,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT("payments,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD("payments,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY("payments,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE("payments,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE("payments,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE("payments,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS("payments,applied_payments"), - - PAYMENTS_APPLIED_PAYMENTS_ACCOUNTING_PERIOD("payments,applied_payments,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES("payments,applied_payments,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY("payments,applied_payments,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT("payments,applied_payments,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE("payments,applied_payments,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS("payments,applied_payments,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY("payments,applied_payments,company"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,applied_payments,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY_EMPLOYEE("payments,applied_payments,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT("payments,applied_payments,contact"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_ACCOUNTING_PERIOD("payments,applied_payments,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY("payments,applied_payments,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY_EMPLOYEE("payments,applied_payments,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_EMPLOYEE("payments,applied_payments,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_EMPLOYEE("payments,applied_payments,employee"), - - PAYMENTS_APPLIED_PAYMENTS_EMPLOYEE_ACCOUNTING_PERIOD("payments,applied_payments,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS("payments,applied_payments,line_items"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("payments,applied_payments,line_items,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES( - "payments,applied_payments,line_items,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,line_items,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,line_items,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,line_items,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,line_items,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY("payments,applied_payments,line_items,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE("payments,applied_payments,line_items,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT("payments,applied_payments,line_items,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("payments,applied_payments,line_items,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE("payments,applied_payments,line_items,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_EMPLOYEE("payments,applied_payments,line_items,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS("payments,applied_payments,line_items,purchase_orders"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY( - "payments,applied_payments,line_items,purchase_orders,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT( - "payments,applied_payments,line_items,purchase_orders,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,applied_payments,line_items,purchase_orders,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE( - "payments,applied_payments,line_items,purchase_orders,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,purchase_orders,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES( - "payments,applied_payments,line_items,tracking_categories"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY( - "payments,applied_payments,line_items,tracking_categories,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT( - "payments,applied_payments,line_items,tracking_categories,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS( - "payments,applied_payments,line_items,tracking_categories,purchase_orders"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,employee"), - - PAYMENTS_APPLIED_PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,line_items,tracking_categories,purchase_orders,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS("payments,applied_payments,purchase_orders"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,applied_payments,purchase_orders,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,purchase_orders,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY("payments,applied_payments,purchase_orders,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT("payments,applied_payments,purchase_orders,contact"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,applied_payments,purchase_orders,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,purchase_orders,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,applied_payments,purchase_orders,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_EMPLOYEE("payments,applied_payments,purchase_orders,employee"), - - PAYMENTS_APPLIED_PAYMENTS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,purchase_orders,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES("payments,applied_payments,tracking_categories"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES( - "payments,applied_payments,tracking_categories,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,tracking_categories,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,tracking_categories,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,tracking_categories,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,tracking_categories,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,applied_payments,tracking_categories,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT("payments,applied_payments,tracking_categories,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE("payments,applied_payments,tracking_categories,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS( - "payments,applied_payments,tracking_categories,purchase_orders"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT( - "payments,applied_payments,tracking_categories,purchase_orders,contact"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,contact,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,applied_payments,tracking_categories,purchase_orders,contact,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,contact,company,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,contact,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE( - "payments,applied_payments,tracking_categories,purchase_orders,employee"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,purchase_orders,employee,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS("payments,applied_vendor_credits"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD("payments,applied_vendor_credits,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY("payments,applied_vendor_credits,company"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE("payments,applied_vendor_credits,company,employee"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT("payments,applied_vendor_credits,contact"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY("payments,applied_vendor_credits,contact,company"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE("payments,applied_vendor_credits,contact,employee"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE("payments,applied_vendor_credits,employee"), - - PAYMENTS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_COMPANY("payments,company"), - - PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,company,accounting_period"), - - PAYMENTS_COMPANY_EMPLOYEE("payments,company,employee"), - - PAYMENTS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("payments,company,employee,accounting_period"), - - PAYMENTS_CONTACT("payments,contact"), - - PAYMENTS_CONTACT_ACCOUNTING_PERIOD("payments,contact,accounting_period"), - - PAYMENTS_CONTACT_COMPANY("payments,contact,company"), - - PAYMENTS_CONTACT_COMPANY_ACCOUNTING_PERIOD("payments,contact,company,accounting_period"), - - PAYMENTS_CONTACT_COMPANY_EMPLOYEE("payments,contact,company,employee"), - - PAYMENTS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("payments,contact,company,employee,accounting_period"), - - PAYMENTS_CONTACT_EMPLOYEE("payments,contact,employee"), - - PAYMENTS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("payments,contact,employee,accounting_period"), - - PAYMENTS_EMPLOYEE("payments,employee"), - - PAYMENTS_EMPLOYEE_ACCOUNTING_PERIOD("payments,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS("payments,line_items"), - - PAYMENTS_LINE_ITEMS_ACCOUNTING_PERIOD("payments,line_items,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES("payments,line_items,applied_credit_notes"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,line_items,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY("payments,line_items,applied_credit_notes,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,line_items,applied_credit_notes,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT("payments,line_items,applied_credit_notes,contact"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,line_items,applied_credit_notes,contact,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,applied_credit_notes,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,line_items,applied_credit_notes,contact,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE("payments,line_items,applied_credit_notes,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS("payments,line_items,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY("payments,line_items,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT("payments,line_items,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE("payments,line_items,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_COMPANY("payments,line_items,company"), - - PAYMENTS_LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("payments,line_items,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE("payments,line_items,company,employee"), - - PAYMENTS_LINE_ITEMS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("payments,line_items,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT("payments,line_items,contact"), - - PAYMENTS_LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("payments,line_items,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY("payments,line_items,contact,company"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_ACCOUNTING_PERIOD("payments,line_items,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE("payments,line_items,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE("payments,line_items,contact,employee"), - - PAYMENTS_LINE_ITEMS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("payments,line_items,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_EMPLOYEE("payments,line_items,employee"), - - PAYMENTS_LINE_ITEMS_EMPLOYEE_ACCOUNTING_PERIOD("payments,line_items,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS("payments,line_items,purchase_orders"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_ACCOUNTING_PERIOD("payments,line_items,purchase_orders,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,line_items,purchase_orders,applied_credit_notes"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,line_items,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,line_items,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,line_items,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,line_items,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,line_items,purchase_orders,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY("payments,line_items,purchase_orders,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE("payments,line_items,purchase_orders,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT("payments,line_items,purchase_orders,contact"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY("payments,line_items,purchase_orders,contact,company"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,purchase_orders,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE("payments,line_items,purchase_orders,contact,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE("payments,line_items,purchase_orders,employee"), - - PAYMENTS_LINE_ITEMS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,purchase_orders,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES("payments,line_items,tracking_categories"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES( - "payments,line_items,tracking_categories,applied_credit_notes"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "payments,line_items,tracking_categories,applied_credit_notes,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "payments,line_items,tracking_categories,applied_credit_notes,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,line_items,tracking_categories,applied_credit_notes,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,line_items,tracking_categories,applied_credit_notes,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS( - "payments,line_items,tracking_categories,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,tracking_categories,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,tracking_categories,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,tracking_categories,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("payments,line_items,tracking_categories,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("payments,line_items,tracking_categories,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY("payments,line_items,tracking_categories,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE("payments,line_items,tracking_categories,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS("payments,line_items,tracking_categories,purchase_orders"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT( - "payments,line_items,tracking_categories,purchase_orders,contact"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,contact,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,line_items,tracking_categories,purchase_orders,contact,company"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,contact,company,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,contact,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE( - "payments,line_items,tracking_categories,purchase_orders,employee"), - - PAYMENTS_LINE_ITEMS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,line_items,tracking_categories,purchase_orders,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS("payments,purchase_orders"), - - PAYMENTS_PURCHASE_ORDERS_ACCOUNTING_PERIOD("payments,purchase_orders,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES("payments,purchase_orders,applied_credit_notes"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY("payments,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT("payments,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE("payments,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS("payments,purchase_orders,applied_vendor_credits"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY("payments,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT("payments,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_COMPANY("payments,purchase_orders,company"), - - PAYMENTS_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD("payments,purchase_orders,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE("payments,purchase_orders,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT("payments,purchase_orders,contact"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD("payments,purchase_orders,contact,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY("payments,purchase_orders,contact,company"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE("payments,purchase_orders,contact,company,employee"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE("payments,purchase_orders,contact,employee"), - - PAYMENTS_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_PURCHASE_ORDERS_EMPLOYEE("payments,purchase_orders,employee"), - - PAYMENTS_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD("payments,purchase_orders,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES("payments,tracking_categories"), - - PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("payments,tracking_categories,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES("payments,tracking_categories,applied_credit_notes"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY( - "payments,tracking_categories,applied_credit_notes,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT( - "payments,tracking_categories,applied_credit_notes,contact"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,tracking_categories,applied_credit_notes,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,tracking_categories,applied_credit_notes,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS("payments,tracking_categories,applied_vendor_credits"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,tracking_categories,applied_vendor_credits,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_vendor_credits,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,tracking_categories,applied_vendor_credits,contact"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,tracking_categories,applied_vendor_credits,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,tracking_categories,applied_vendor_credits,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,tracking_categories,applied_vendor_credits,employee"), - - PAYMENTS_TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,tracking_categories,company"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("payments,tracking_categories,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE("payments,tracking_categories,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT("payments,tracking_categories,contact"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("payments,tracking_categories,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY("payments,tracking_categories,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE("payments,tracking_categories,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE("payments,tracking_categories,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE("payments,tracking_categories,employee"), - - PAYMENTS_TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD("payments,tracking_categories,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS("payments,tracking_categories,purchase_orders"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "payments,tracking_categories,purchase_orders,applied_credit_notes"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "payments,tracking_categories,purchase_orders,applied_credit_notes,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_credit_notes,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "payments,tracking_categories,purchase_orders,applied_vendor_credits"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY("payments,tracking_categories,purchase_orders,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT("payments,tracking_categories,purchase_orders,contact"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,contact,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY( - "payments,tracking_categories,purchase_orders,contact,company"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,contact,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "payments,tracking_categories,purchase_orders,contact,company,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE( - "payments,tracking_categories,purchase_orders,contact,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,contact,employee,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE("payments,tracking_categories,purchase_orders,employee"), - - PAYMENTS_TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "payments,tracking_categories,purchase_orders,employee,accounting_period"), - - PURCHASE_ORDERS("purchase_orders"), - - PURCHASE_ORDERS_ACCOUNTING_PERIOD("purchase_orders,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES("purchase_orders,applied_credit_notes"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD("purchase_orders,applied_credit_notes,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "purchase_orders,applied_credit_notes,applied_vendor_credits"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY("purchase_orders,applied_credit_notes,company"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE("purchase_orders,applied_credit_notes,company,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT("purchase_orders,applied_credit_notes,contact"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,contact,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY("purchase_orders,applied_credit_notes,contact,company"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "purchase_orders,applied_credit_notes,contact,company,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE("purchase_orders,applied_credit_notes,contact,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE("purchase_orders,applied_credit_notes,employee"), - - PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_credit_notes,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS("purchase_orders,applied_vendor_credits"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY("purchase_orders,applied_vendor_credits,company"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE("purchase_orders,applied_vendor_credits,company,employee"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT("purchase_orders,applied_vendor_credits,contact"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,contact,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY("purchase_orders,applied_vendor_credits,contact,company"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "purchase_orders,applied_vendor_credits,contact,company,employee"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE("purchase_orders,applied_vendor_credits,contact,employee"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE("purchase_orders,applied_vendor_credits,employee"), - - PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,applied_vendor_credits,employee,accounting_period"), - - PURCHASE_ORDERS_COMPANY("purchase_orders,company"), - - PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD("purchase_orders,company,accounting_period"), - - PURCHASE_ORDERS_COMPANY_EMPLOYEE("purchase_orders,company,employee"), - - PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("purchase_orders,company,employee,accounting_period"), - - PURCHASE_ORDERS_CONTACT("purchase_orders,contact"), - - PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD("purchase_orders,contact,accounting_period"), - - PURCHASE_ORDERS_CONTACT_COMPANY("purchase_orders,contact,company"), - - PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD("purchase_orders,contact,company,accounting_period"), - - PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE("purchase_orders,contact,company,employee"), - - PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "purchase_orders,contact,company,employee,accounting_period"), - - PURCHASE_ORDERS_CONTACT_EMPLOYEE("purchase_orders,contact,employee"), - - PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("purchase_orders,contact,employee,accounting_period"), - - PURCHASE_ORDERS_EMPLOYEE("purchase_orders,employee"), - - PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD("purchase_orders,employee,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES("tracking_categories,applied_credit_notes"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "tracking_categories,applied_credit_notes,applied_vendor_credits"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "tracking_categories,applied_credit_notes,applied_vendor_credits,company"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "tracking_categories,applied_credit_notes,applied_vendor_credits,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY("tracking_categories,applied_credit_notes,company"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "tracking_categories,applied_credit_notes,company,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT("tracking_categories,applied_credit_notes,contact"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,contact,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "tracking_categories,applied_credit_notes,contact,company"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,contact,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,applied_credit_notes,contact,company,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "tracking_categories,applied_credit_notes,contact,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE("tracking_categories,applied_credit_notes,employee"), - - TRACKING_CATEGORIES_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_credit_notes,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS("tracking_categories,applied_vendor_credits"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY("tracking_categories,applied_vendor_credits,company"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "tracking_categories,applied_vendor_credits,company,employee"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT("tracking_categories,applied_vendor_credits,contact"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,contact,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "tracking_categories,applied_vendor_credits,contact,company"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,contact,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,applied_vendor_credits,contact,company,employee"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "tracking_categories,applied_vendor_credits,contact,employee"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE("tracking_categories,applied_vendor_credits,employee"), - - TRACKING_CATEGORIES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,applied_vendor_credits,employee,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_COMPANY_EMPLOYEE("tracking_categories,company,employee"), - - TRACKING_CATEGORIES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,company,employee,accounting_period"), - - TRACKING_CATEGORIES_CONTACT("tracking_categories,contact"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("tracking_categories,contact,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY("tracking_categories,contact,company"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,contact,company,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE("tracking_categories,contact,company,employee"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_EMPLOYEE("tracking_categories,contact,employee"), - - TRACKING_CATEGORIES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_EMPLOYEE("tracking_categories,employee"), - - TRACKING_CATEGORIES_EMPLOYEE_ACCOUNTING_PERIOD("tracking_categories,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS("tracking_categories,purchase_orders"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_ACCOUNTING_PERIOD("tracking_categories,purchase_orders,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES( - "tracking_categories,purchase_orders,applied_credit_notes"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,applied_vendor_credits,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY( - "tracking_categories,purchase_orders,applied_credit_notes,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT( - "tracking_categories,purchase_orders,applied_credit_notes,contact"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,contact,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY( - "tracking_categories,purchase_orders,applied_credit_notes,contact,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,contact,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,contact,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE( - "tracking_categories,purchase_orders,applied_credit_notes,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_CREDIT_NOTES_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_credit_notes,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS( - "tracking_categories,purchase_orders,applied_vendor_credits"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY( - "tracking_categories,purchase_orders,applied_vendor_credits,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_vendor_credits,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT( - "tracking_categories,purchase_orders,applied_vendor_credits,contact"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE( - "tracking_categories,purchase_orders,applied_vendor_credits,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_APPLIED_VENDOR_CREDITS_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,applied_vendor_credits,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY("tracking_categories,purchase_orders,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE("tracking_categories,purchase_orders,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT("tracking_categories,purchase_orders,contact"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,contact,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY("tracking_categories,purchase_orders,contact,company"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,contact,company,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE( - "tracking_categories,purchase_orders,contact,company,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_COMPANY_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,contact,company,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE("tracking_categories,purchase_orders,contact,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_CONTACT_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,contact,employee,accounting_period"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE("tracking_categories,purchase_orders,employee"), - - TRACKING_CATEGORIES_PURCHASE_ORDERS_EMPLOYEE_ACCOUNTING_PERIOD( - "tracking_categories,purchase_orders,employee,accounting_period"); - - private final String value; - - InvoicesRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesRetrieveRequestExpandItem.java new file mode 100644 index 000000000..0c2fe078c --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/invoices/types/InvoicesRetrieveRequestExpandItem.java @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.invoices.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum InvoicesRetrieveRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + APPLIED_CREDIT_NOTES("applied_credit_notes"), + + APPLIED_PAYMENTS("applied_payments"), + + APPLIED_VENDOR_CREDITS("applied_vendor_credits"), + + COMPANY("company"), + + CONTACT("contact"), + + EMPLOYEE("employee"), + + LINE_ITEMS("line_items"), + + PAYMENT_TERM("payment_term"), + + PAYMENTS("payments"), + + PURCHASE_ORDERS("purchase_orders"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + InvoicesRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/issues/AsyncIssuesClient.java b/src/main/java/com/merge/api/resources/accounting/issues/AsyncIssuesClient.java new file mode 100644 index 000000000..84dd6a04f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/issues/AsyncIssuesClient.java @@ -0,0 +1,64 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.issues; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.issues.requests.IssuesListRequest; +import com.merge.api.resources.accounting.types.Issue; +import com.merge.api.resources.accounting.types.PaginatedIssueList; +import java.util.concurrent.CompletableFuture; + +public class AsyncIssuesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawIssuesClient rawClient; + + public AsyncIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawIssuesClient withRawResponse() { + return this.rawClient; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/issues/AsyncRawIssuesClient.java b/src/main/java/com/merge/api/resources/accounting/issues/AsyncRawIssuesClient.java new file mode 100644 index 000000000..810f86e4a --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/issues/AsyncRawIssuesClient.java @@ -0,0 +1,226 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.issues.requests.IssuesListRequest; +import com.merge.api.resources.accounting.types.Issue; +import com.merge.api.resources.accounting.types.PaginatedIssueList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawIssuesClient { + protected final ClientOptions clientOptions; + + public AsyncRawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list( + IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/issues/IssuesClient.java b/src/main/java/com/merge/api/resources/accounting/issues/IssuesClient.java index 43f031b0f..ef618408a 100644 --- a/src/main/java/com/merge/api/resources/accounting/issues/IssuesClient.java +++ b/src/main/java/com/merge/api/resources/accounting/issues/IssuesClient.java @@ -3,169 +3,61 @@ */ package com.merge.api.resources.accounting.issues; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.issues.requests.IssuesListRequest; import com.merge.api.resources.accounting.types.Issue; import com.merge.api.resources.accounting.types.PaginatedIssueList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class IssuesClient { protected final ClientOptions clientOptions; + private final RawIssuesClient rawClient; + public IssuesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawIssuesClient withRawResponse() { + return this.rawClient; } /** * Gets all issues for Organization. */ public PaginatedIssueList list() { - return list(IssuesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/issues"); - if (request.getAccountToken().isPresent()) { - httpUrl.addQueryParameter("account_token", request.getAccountToken().get()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getFirstIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_after", - request.getFirstIncidentTimeAfter().get().toString()); - } - if (request.getFirstIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_before", - request.getFirstIncidentTimeBefore().get().toString()); - } - if (request.getIncludeMuted().isPresent()) { - httpUrl.addQueryParameter("include_muted", request.getIncludeMuted().get()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getLastIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_after", - request.getLastIncidentTimeAfter().get().toString()); - } - if (request.getLastIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_before", - request.getLastIncidentTimeBefore().get().toString()); - } - if (request.getLinkedAccountId().isPresent()) { - httpUrl.addQueryParameter( - "linked_account_id", request.getLinkedAccountId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Get a specific issue. */ public Issue retrieve(String id) { - return retrieve(id, null); + return this.rawClient.retrieve(id).body(); } /** * Get a specific issue. */ public Issue retrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/issues") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/issues/RawIssuesClient.java b/src/main/java/com/merge/api/resources/accounting/issues/RawIssuesClient.java new file mode 100644 index 000000000..658a78628 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/issues/RawIssuesClient.java @@ -0,0 +1,194 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.issues.requests.IssuesListRequest; +import com.merge.api.resources.accounting.types.Issue; +import com.merge.api.resources.accounting.types.PaginatedIssueList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawIssuesClient { + protected final ClientOptions clientOptions; + + public RawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/items/AsyncItemsClient.java b/src/main/java/com/merge/api/resources/accounting/items/AsyncItemsClient.java new file mode 100644 index 000000000..6e25f43eb --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/items/AsyncItemsClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.items; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.items.requests.ItemsListRequest; +import com.merge.api.resources.accounting.items.requests.ItemsRetrieveRequest; +import com.merge.api.resources.accounting.types.Item; +import com.merge.api.resources.accounting.types.PaginatedItemList; +import java.util.concurrent.CompletableFuture; + +public class AsyncItemsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawItemsClient rawClient; + + public AsyncItemsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawItemsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawItemsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Item objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Item objects. + */ + public CompletableFuture list(ItemsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Item objects. + */ + public CompletableFuture list(ItemsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Item object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Item object with the given id. + */ + public CompletableFuture retrieve(String id, ItemsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Item object with the given id. + */ + public CompletableFuture retrieve(String id, ItemsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/items/AsyncRawItemsClient.java b/src/main/java/com/merge/api/resources/accounting/items/AsyncRawItemsClient.java new file mode 100644 index 000000000..5e7edc231 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/items/AsyncRawItemsClient.java @@ -0,0 +1,257 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.items; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.items.requests.ItemsListRequest; +import com.merge.api.resources.accounting.items.requests.ItemsRetrieveRequest; +import com.merge.api.resources.accounting.types.Item; +import com.merge.api.resources.accounting.types.PaginatedItemList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawItemsClient { + protected final ClientOptions clientOptions; + + public AsyncRawItemsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Item objects. + */ + public CompletableFuture> list() { + return list(ItemsListRequest.builder().build()); + } + + /** + * Returns a list of Item objects. + */ + public CompletableFuture> list(ItemsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Item objects. + */ + public CompletableFuture> list( + ItemsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/items"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedItemList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Item object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, ItemsRetrieveRequest.builder().build()); + } + + /** + * Returns an Item object with the given id. + */ + public CompletableFuture> retrieve(String id, ItemsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Item object with the given id. + */ + public CompletableFuture> retrieve( + String id, ItemsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/items") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Item.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/items/ItemsClient.java b/src/main/java/com/merge/api/resources/accounting/items/ItemsClient.java index f5d04329c..6a98aee90 100644 --- a/src/main/java/com/merge/api/resources/accounting/items/ItemsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/items/ItemsClient.java @@ -3,187 +3,69 @@ */ package com.merge.api.resources.accounting.items; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.items.requests.ItemsListRequest; import com.merge.api.resources.accounting.items.requests.ItemsRetrieveRequest; import com.merge.api.resources.accounting.types.Item; import com.merge.api.resources.accounting.types.PaginatedItemList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ItemsClient { protected final ClientOptions clientOptions; + private final RawItemsClient rawClient; + public ItemsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawItemsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawItemsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Item objects. */ public PaginatedItemList list() { - return list(ItemsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Item objects. */ public PaginatedItemList list(ItemsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Item objects. */ public PaginatedItemList list(ItemsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/items"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedItemList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an Item object with the given id. */ public Item retrieve(String id) { - return retrieve(id, ItemsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Item object with the given id. */ public Item retrieve(String id, ItemsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Item object with the given id. */ public Item retrieve(String id, ItemsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/items") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Item.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/items/RawItemsClient.java b/src/main/java/com/merge/api/resources/accounting/items/RawItemsClient.java new file mode 100644 index 000000000..2e23751c3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/items/RawItemsClient.java @@ -0,0 +1,224 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.items; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.items.requests.ItemsListRequest; +import com.merge.api.resources.accounting.items.requests.ItemsRetrieveRequest; +import com.merge.api.resources.accounting.types.Item; +import com.merge.api.resources.accounting.types.PaginatedItemList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawItemsClient { + protected final ClientOptions clientOptions; + + public RawItemsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Item objects. + */ + public MergeApiHttpResponse list() { + return list(ItemsListRequest.builder().build()); + } + + /** + * Returns a list of Item objects. + */ + public MergeApiHttpResponse list(ItemsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Item objects. + */ + public MergeApiHttpResponse list(ItemsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/items"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedItemList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Item object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, ItemsRetrieveRequest.builder().build()); + } + + /** + * Returns an Item object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, ItemsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Item object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, ItemsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/items") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Item.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/items/requests/ItemsListRequest.java b/src/main/java/com/merge/api/resources/accounting/items/requests/ItemsListRequest.java index 8116647af..9be1888d0 100644 --- a/src/main/java/com/merge/api/resources/accounting/items/requests/ItemsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/items/requests/ItemsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.items.types.ItemsListRequestExpand; +import com.merge.api.resources.accounting.items.types.ItemsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ItemsListRequest.Builder.class) public final class ItemsListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -30,8 +34,6 @@ public final class ItemsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -53,11 +55,11 @@ public final class ItemsListRequest { private final Map additionalProperties; private ItemsListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -68,11 +70,11 @@ private ItemsListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -85,6 +87,14 @@ private ItemsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return items for this company. */ @@ -117,14 +127,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -209,11 +211,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(ItemsListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -228,11 +230,11 @@ private boolean equalTo(ItemsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -255,6 +257,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -263,8 +267,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -289,11 +291,11 @@ public static final class Builder { private Builder() {} public Builder from(ItemsListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -306,6 +308,22 @@ public Builder from(ItemsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(ItemsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -350,17 +368,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(ItemsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -462,11 +469,11 @@ public Builder showEnumOrigins(String showEnumOrigins) { public ItemsListRequest build() { return new ItemsListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/items/requests/ItemsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/items/requests/ItemsRetrieveRequest.java index f360d2a78..388ae35f0 100644 --- a/src/main/java/com/merge/api/resources/accounting/items/requests/ItemsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/items/requests/ItemsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.items.types.ItemsRetrieveRequestExpand; +import com.merge.api.resources.accounting.items.types.ItemsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,10 +23,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ItemsRetrieveRequest.Builder.class) public final class ItemsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -32,13 +36,15 @@ public final class ItemsRetrieveRequest { private final Map additionalProperties; private ItemsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -48,7 +54,7 @@ private ItemsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -60,6 +66,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -90,13 +104,15 @@ public Map getAdditionalProperties() { private boolean equalTo(ItemsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -110,10 +126,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -126,22 +144,28 @@ private Builder() {} public Builder from(ItemsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(ItemsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(ItemsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -153,6 +177,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -177,7 +212,7 @@ public Builder showEnumOrigins(String showEnumOrigins) { public ItemsRetrieveRequest build() { return new ItemsRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/items/types/ItemsListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/items/types/ItemsListRequestExpand.java deleted file mode 100644 index f9daf6286..000000000 --- a/src/main/java/com/merge/api/resources/accounting/items/types/ItemsListRequestExpand.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.items.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ItemsListRequestExpand { - COMPANY("company"), - - COMPANY_PURCHASE_TAX_RATE("company,purchase_tax_rate"), - - COMPANY_SALES_TAX_RATE("company,sales_tax_rate"), - - COMPANY_SALES_TAX_RATE_PURCHASE_TAX_RATE("company,sales_tax_rate,purchase_tax_rate"), - - PURCHASE_ACCOUNT("purchase_account"), - - PURCHASE_ACCOUNT_COMPANY("purchase_account,company"), - - PURCHASE_ACCOUNT_COMPANY_PURCHASE_TAX_RATE("purchase_account,company,purchase_tax_rate"), - - PURCHASE_ACCOUNT_COMPANY_SALES_TAX_RATE("purchase_account,company,sales_tax_rate"), - - PURCHASE_ACCOUNT_COMPANY_SALES_TAX_RATE_PURCHASE_TAX_RATE( - "purchase_account,company,sales_tax_rate,purchase_tax_rate"), - - PURCHASE_ACCOUNT_PURCHASE_TAX_RATE("purchase_account,purchase_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT("purchase_account,sales_account"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_COMPANY("purchase_account,sales_account,company"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_COMPANY_PURCHASE_TAX_RATE( - "purchase_account,sales_account,company,purchase_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_COMPANY_SALES_TAX_RATE("purchase_account,sales_account,company,sales_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_COMPANY_SALES_TAX_RATE_PURCHASE_TAX_RATE( - "purchase_account,sales_account,company,sales_tax_rate,purchase_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_PURCHASE_TAX_RATE("purchase_account,sales_account,purchase_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_SALES_TAX_RATE("purchase_account,sales_account,sales_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_SALES_TAX_RATE_PURCHASE_TAX_RATE( - "purchase_account,sales_account,sales_tax_rate,purchase_tax_rate"), - - PURCHASE_ACCOUNT_SALES_TAX_RATE("purchase_account,sales_tax_rate"), - - PURCHASE_ACCOUNT_SALES_TAX_RATE_PURCHASE_TAX_RATE("purchase_account,sales_tax_rate,purchase_tax_rate"), - - PURCHASE_TAX_RATE("purchase_tax_rate"), - - SALES_ACCOUNT("sales_account"), - - SALES_ACCOUNT_COMPANY("sales_account,company"), - - SALES_ACCOUNT_COMPANY_PURCHASE_TAX_RATE("sales_account,company,purchase_tax_rate"), - - SALES_ACCOUNT_COMPANY_SALES_TAX_RATE("sales_account,company,sales_tax_rate"), - - SALES_ACCOUNT_COMPANY_SALES_TAX_RATE_PURCHASE_TAX_RATE("sales_account,company,sales_tax_rate,purchase_tax_rate"), - - SALES_ACCOUNT_PURCHASE_TAX_RATE("sales_account,purchase_tax_rate"), - - SALES_ACCOUNT_SALES_TAX_RATE("sales_account,sales_tax_rate"), - - SALES_ACCOUNT_SALES_TAX_RATE_PURCHASE_TAX_RATE("sales_account,sales_tax_rate,purchase_tax_rate"), - - SALES_TAX_RATE("sales_tax_rate"), - - SALES_TAX_RATE_PURCHASE_TAX_RATE("sales_tax_rate,purchase_tax_rate"); - - private final String value; - - ItemsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/items/types/ItemsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/items/types/ItemsListRequestExpandItem.java new file mode 100644 index 000000000..3795d9fbb --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/items/types/ItemsListRequestExpandItem.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.items.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ItemsListRequestExpandItem { + COMPANY("company"), + + PURCHASE_ACCOUNT("purchase_account"), + + PURCHASE_TAX_RATE("purchase_tax_rate"), + + SALES_ACCOUNT("sales_account"), + + SALES_TAX_RATE("sales_tax_rate"); + + private final String value; + + ItemsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/items/types/ItemsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/items/types/ItemsRetrieveRequestExpand.java deleted file mode 100644 index 938e6ba62..000000000 --- a/src/main/java/com/merge/api/resources/accounting/items/types/ItemsRetrieveRequestExpand.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.items.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ItemsRetrieveRequestExpand { - COMPANY("company"), - - COMPANY_PURCHASE_TAX_RATE("company,purchase_tax_rate"), - - COMPANY_SALES_TAX_RATE("company,sales_tax_rate"), - - COMPANY_SALES_TAX_RATE_PURCHASE_TAX_RATE("company,sales_tax_rate,purchase_tax_rate"), - - PURCHASE_ACCOUNT("purchase_account"), - - PURCHASE_ACCOUNT_COMPANY("purchase_account,company"), - - PURCHASE_ACCOUNT_COMPANY_PURCHASE_TAX_RATE("purchase_account,company,purchase_tax_rate"), - - PURCHASE_ACCOUNT_COMPANY_SALES_TAX_RATE("purchase_account,company,sales_tax_rate"), - - PURCHASE_ACCOUNT_COMPANY_SALES_TAX_RATE_PURCHASE_TAX_RATE( - "purchase_account,company,sales_tax_rate,purchase_tax_rate"), - - PURCHASE_ACCOUNT_PURCHASE_TAX_RATE("purchase_account,purchase_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT("purchase_account,sales_account"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_COMPANY("purchase_account,sales_account,company"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_COMPANY_PURCHASE_TAX_RATE( - "purchase_account,sales_account,company,purchase_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_COMPANY_SALES_TAX_RATE("purchase_account,sales_account,company,sales_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_COMPANY_SALES_TAX_RATE_PURCHASE_TAX_RATE( - "purchase_account,sales_account,company,sales_tax_rate,purchase_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_PURCHASE_TAX_RATE("purchase_account,sales_account,purchase_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_SALES_TAX_RATE("purchase_account,sales_account,sales_tax_rate"), - - PURCHASE_ACCOUNT_SALES_ACCOUNT_SALES_TAX_RATE_PURCHASE_TAX_RATE( - "purchase_account,sales_account,sales_tax_rate,purchase_tax_rate"), - - PURCHASE_ACCOUNT_SALES_TAX_RATE("purchase_account,sales_tax_rate"), - - PURCHASE_ACCOUNT_SALES_TAX_RATE_PURCHASE_TAX_RATE("purchase_account,sales_tax_rate,purchase_tax_rate"), - - PURCHASE_TAX_RATE("purchase_tax_rate"), - - SALES_ACCOUNT("sales_account"), - - SALES_ACCOUNT_COMPANY("sales_account,company"), - - SALES_ACCOUNT_COMPANY_PURCHASE_TAX_RATE("sales_account,company,purchase_tax_rate"), - - SALES_ACCOUNT_COMPANY_SALES_TAX_RATE("sales_account,company,sales_tax_rate"), - - SALES_ACCOUNT_COMPANY_SALES_TAX_RATE_PURCHASE_TAX_RATE("sales_account,company,sales_tax_rate,purchase_tax_rate"), - - SALES_ACCOUNT_PURCHASE_TAX_RATE("sales_account,purchase_tax_rate"), - - SALES_ACCOUNT_SALES_TAX_RATE("sales_account,sales_tax_rate"), - - SALES_ACCOUNT_SALES_TAX_RATE_PURCHASE_TAX_RATE("sales_account,sales_tax_rate,purchase_tax_rate"), - - SALES_TAX_RATE("sales_tax_rate"), - - SALES_TAX_RATE_PURCHASE_TAX_RATE("sales_tax_rate,purchase_tax_rate"); - - private final String value; - - ItemsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/items/types/ItemsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/items/types/ItemsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..926158b83 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/items/types/ItemsRetrieveRequestExpandItem.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.items.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ItemsRetrieveRequestExpandItem { + COMPANY("company"), + + PURCHASE_ACCOUNT("purchase_account"), + + PURCHASE_TAX_RATE("purchase_tax_rate"), + + SALES_ACCOUNT("sales_account"), + + SALES_TAX_RATE("sales_tax_rate"); + + private final String value; + + ItemsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/journalentries/AsyncJournalEntriesClient.java b/src/main/java/com/merge/api/resources/accounting/journalentries/AsyncJournalEntriesClient.java new file mode 100644 index 000000000..2106457eb --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/journalentries/AsyncJournalEntriesClient.java @@ -0,0 +1,157 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.journalentries; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesLinesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesListRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesRetrieveRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntryEndpointRequest; +import com.merge.api.resources.accounting.types.JournalEntry; +import com.merge.api.resources.accounting.types.JournalEntryResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedJournalEntryList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncJournalEntriesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawJournalEntriesClient rawClient; + + public AsyncJournalEntriesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawJournalEntriesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawJournalEntriesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of JournalEntry objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of JournalEntry objects. + */ + public CompletableFuture list(JournalEntriesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of JournalEntry objects. + */ + public CompletableFuture list( + JournalEntriesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a JournalEntry object with the given values. + */ + public CompletableFuture create(JournalEntryEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a JournalEntry object with the given values. + */ + public CompletableFuture create( + JournalEntryEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a JournalEntry object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a JournalEntry object with the given id. + */ + public CompletableFuture retrieve(String id, JournalEntriesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a JournalEntry object with the given id. + */ + public CompletableFuture retrieve( + String id, JournalEntriesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture linesRemoteFieldClassesList() { + return this.rawClient.linesRemoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture linesRemoteFieldClassesList( + JournalEntriesLinesRemoteFieldClassesListRequest request) { + return this.rawClient.linesRemoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture linesRemoteFieldClassesList( + JournalEntriesLinesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient + .linesRemoteFieldClassesList(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns metadata for JournalEntry POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for JournalEntry POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + JournalEntriesRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + JournalEntriesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/journalentries/AsyncRawJournalEntriesClient.java b/src/main/java/com/merge/api/resources/accounting/journalentries/AsyncRawJournalEntriesClient.java new file mode 100644 index 000000000..2ed919fed --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/journalentries/AsyncRawJournalEntriesClient.java @@ -0,0 +1,619 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.journalentries; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesLinesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesListRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesRetrieveRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntryEndpointRequest; +import com.merge.api.resources.accounting.types.JournalEntry; +import com.merge.api.resources.accounting.types.JournalEntryResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedJournalEntryList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawJournalEntriesClient { + protected final ClientOptions clientOptions; + + public AsyncRawJournalEntriesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of JournalEntry objects. + */ + public CompletableFuture> list() { + return list(JournalEntriesListRequest.builder().build()); + } + + /** + * Returns a list of JournalEntry objects. + */ + public CompletableFuture> list(JournalEntriesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of JournalEntry objects. + */ + public CompletableFuture> list( + JournalEntriesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedJournalEntryList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a JournalEntry object with the given values. + */ + public CompletableFuture> create(JournalEntryEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a JournalEntry object with the given values. + */ + public CompletableFuture> create( + JournalEntryEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JournalEntryResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a JournalEntry object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, JournalEntriesRetrieveRequest.builder().build()); + } + + /** + * Returns a JournalEntry object with the given id. + */ + public CompletableFuture> retrieve( + String id, JournalEntriesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a JournalEntry object with the given id. + */ + public CompletableFuture> retrieve( + String id, JournalEntriesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JournalEntry.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> linesRemoteFieldClassesList() { + return linesRemoteFieldClassesList( + JournalEntriesLinesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> linesRemoteFieldClassesList( + JournalEntriesLinesRemoteFieldClassesListRequest request) { + return linesRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> linesRemoteFieldClassesList( + JournalEntriesLinesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries/lines/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for JournalEntry POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for JournalEntry POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + JournalEntriesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + JournalEntriesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + JournalEntriesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/journalentries/JournalEntriesClient.java b/src/main/java/com/merge/api/resources/accounting/journalentries/JournalEntriesClient.java index 77c0ab52c..299003083 100644 --- a/src/main/java/com/merge/api/resources/accounting/journalentries/JournalEntriesClient.java +++ b/src/main/java/com/merge/api/resources/accounting/journalentries/JournalEntriesClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.journalentries; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesLinesRemoteFieldClassesListRequest; import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesListRequest; @@ -19,252 +15,85 @@ import com.merge.api.resources.accounting.types.MetaResponse; import com.merge.api.resources.accounting.types.PaginatedJournalEntryList; import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class JournalEntriesClient { protected final ClientOptions clientOptions; + private final RawJournalEntriesClient rawClient; + public JournalEntriesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawJournalEntriesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawJournalEntriesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of JournalEntry objects. */ public PaginatedJournalEntryList list() { - return list(JournalEntriesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of JournalEntry objects. */ public PaginatedJournalEntryList list(JournalEntriesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of JournalEntry objects. */ public PaginatedJournalEntryList list(JournalEntriesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/journal-entries"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getTransactionDateAfter().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_after", - request.getTransactionDateAfter().get().toString()); - } - if (request.getTransactionDateBefore().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_before", - request.getTransactionDateBefore().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedJournalEntryList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a JournalEntry object with the given values. */ public JournalEntryResponse create(JournalEntryEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a JournalEntry object with the given values. */ public JournalEntryResponse create(JournalEntryEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/journal-entries"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JournalEntryResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a JournalEntry object with the given id. */ public JournalEntry retrieve(String id) { - return retrieve(id, JournalEntriesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a JournalEntry object with the given id. */ public JournalEntry retrieve(String id, JournalEntriesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a JournalEntry object with the given id. */ public JournalEntry retrieve(String id, JournalEntriesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/journal-entries") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JournalEntry.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList linesRemoteFieldClassesList() { - return linesRemoteFieldClassesList( - JournalEntriesLinesRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.linesRemoteFieldClassesList().body(); } /** @@ -272,7 +101,7 @@ public PaginatedRemoteFieldClassList linesRemoteFieldClassesList() { */ public PaginatedRemoteFieldClassList linesRemoteFieldClassesList( JournalEntriesLinesRemoteFieldClassesListRequest request) { - return linesRemoteFieldClassesList(request, null); + return this.rawClient.linesRemoteFieldClassesList(request).body(); } /** @@ -280,113 +109,37 @@ public PaginatedRemoteFieldClassList linesRemoteFieldClassesList( */ public PaginatedRemoteFieldClassList linesRemoteFieldClassesList( JournalEntriesLinesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/journal-entries/lines/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .linesRemoteFieldClassesList(request, requestOptions) + .body(); } /** * Returns metadata for JournalEntry POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for JournalEntry POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/journal-entries/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - JournalEntriesRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(JournalEntriesRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -394,56 +147,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(JournalEntriesRemote */ public PaginatedRemoteFieldClassList remoteFieldClassesList( JournalEntriesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/journal-entries/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/journalentries/RawJournalEntriesClient.java b/src/main/java/com/merge/api/resources/accounting/journalentries/RawJournalEntriesClient.java new file mode 100644 index 000000000..49648333b --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/journalentries/RawJournalEntriesClient.java @@ -0,0 +1,531 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.journalentries; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesLinesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesListRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntriesRetrieveRequest; +import com.merge.api.resources.accounting.journalentries.requests.JournalEntryEndpointRequest; +import com.merge.api.resources.accounting.types.JournalEntry; +import com.merge.api.resources.accounting.types.JournalEntryResponse; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedJournalEntryList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawJournalEntriesClient { + protected final ClientOptions clientOptions; + + public RawJournalEntriesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of JournalEntry objects. + */ + public MergeApiHttpResponse list() { + return list(JournalEntriesListRequest.builder().build()); + } + + /** + * Returns a list of JournalEntry objects. + */ + public MergeApiHttpResponse list(JournalEntriesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of JournalEntry objects. + */ + public MergeApiHttpResponse list( + JournalEntriesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedJournalEntryList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a JournalEntry object with the given values. + */ + public MergeApiHttpResponse create(JournalEntryEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a JournalEntry object with the given values. + */ + public MergeApiHttpResponse create( + JournalEntryEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JournalEntryResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a JournalEntry object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, JournalEntriesRetrieveRequest.builder().build()); + } + + /** + * Returns a JournalEntry object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, JournalEntriesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a JournalEntry object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, JournalEntriesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JournalEntry.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse linesRemoteFieldClassesList() { + return linesRemoteFieldClassesList( + JournalEntriesLinesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse linesRemoteFieldClassesList( + JournalEntriesLinesRemoteFieldClassesListRequest request) { + return linesRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse linesRemoteFieldClassesList( + JournalEntriesLinesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries/lines/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for JournalEntry POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for JournalEntry POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + JournalEntriesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + JournalEntriesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + JournalEntriesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/journal-entries/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/journalentries/requests/JournalEntriesListRequest.java b/src/main/java/com/merge/api/resources/accounting/journalentries/requests/JournalEntriesListRequest.java index c4302e359..0624a1137 100644 --- a/src/main/java/com/merge/api/resources/accounting/journalentries/requests/JournalEntriesListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/journalentries/requests/JournalEntriesListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.journalentries.types.JournalEntriesListRequestExpand; +import com.merge.api.resources.accounting.journalentries.types.JournalEntriesListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = JournalEntriesListRequest.Builder.class) public final class JournalEntriesListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -30,8 +34,6 @@ public final class JournalEntriesListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -55,11 +57,11 @@ public final class JournalEntriesListRequest { private final Map additionalProperties; private JournalEntriesListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -71,11 +73,11 @@ private JournalEntriesListRequest( Optional transactionDateAfter, Optional transactionDateBefore, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -89,6 +91,14 @@ private JournalEntriesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return journal entries for this company. */ @@ -121,14 +131,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -221,11 +223,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(JournalEntriesListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -241,11 +243,11 @@ private boolean equalTo(JournalEntriesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -269,6 +271,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -277,8 +281,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -305,11 +307,11 @@ public static final class Builder { private Builder() {} public Builder from(JournalEntriesListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -323,6 +325,22 @@ public Builder from(JournalEntriesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(JournalEntriesListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -367,17 +385,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(JournalEntriesListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -490,11 +497,11 @@ public Builder transactionDateBefore(OffsetDateTime transactionDateBefore) { public JournalEntriesListRequest build() { return new JournalEntriesListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/accounting/journalentries/requests/JournalEntriesRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/journalentries/requests/JournalEntriesRetrieveRequest.java index f199d3218..30dcaf277 100644 --- a/src/main/java/com/merge/api/resources/accounting/journalentries/requests/JournalEntriesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/journalentries/requests/JournalEntriesRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.journalentries.types.JournalEntriesRetrieveRequestExpand; +import com.merge.api.resources.accounting.journalentries.types.JournalEntriesRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,22 +23,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = JournalEntriesRetrieveRequest.Builder.class) public final class JournalEntriesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private JournalEntriesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -44,7 +50,7 @@ private JournalEntriesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -64,6 +70,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -78,12 +92,13 @@ public Map getAdditionalProperties() { private boolean equalTo(JournalEntriesRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -97,12 +112,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -112,20 +129,26 @@ public Builder from(JournalEntriesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(JournalEntriesRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(JournalEntriesRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -148,9 +171,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public JournalEntriesRetrieveRequest build() { return new JournalEntriesRetrieveRequest( - expand, includeRemoteData, includeRemoteFields, additionalProperties); + expand, includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesListRequestExpand.java deleted file mode 100644 index 4bc04dfb9..000000000 --- a/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesListRequestExpand.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.journalentries.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum JournalEntriesListRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - APPLIED_PAYMENTS("applied_payments"), - - APPLIED_PAYMENTS_ACCOUNTING_PERIOD("applied_payments,accounting_period"), - - APPLIED_PAYMENTS_COMPANY("applied_payments,company"), - - APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("applied_payments,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES("applied_payments,tracking_categories"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("applied_payments,tracking_categories,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("applied_payments,tracking_categories,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,company,accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - LINES("lines"), - - LINES_ACCOUNTING_PERIOD("lines,accounting_period"), - - LINES_APPLIED_PAYMENTS("lines,applied_payments"), - - LINES_APPLIED_PAYMENTS_ACCOUNTING_PERIOD("lines,applied_payments,accounting_period"), - - LINES_APPLIED_PAYMENTS_COMPANY("lines,applied_payments,company"), - - LINES_APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("lines,applied_payments,company,accounting_period"), - - LINES_APPLIED_PAYMENTS_TRACKING_CATEGORIES("lines,applied_payments,tracking_categories"), - - LINES_APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "lines,applied_payments,tracking_categories,accounting_period"), - - LINES_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("lines,applied_payments,tracking_categories,company"), - - LINES_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "lines,applied_payments,tracking_categories,company,accounting_period"), - - LINES_COMPANY("lines,company"), - - LINES_COMPANY_ACCOUNTING_PERIOD("lines,company,accounting_period"), - - LINES_PAYMENTS("lines,payments"), - - LINES_PAYMENTS_ACCOUNTING_PERIOD("lines,payments,accounting_period"), - - LINES_PAYMENTS_APPLIED_PAYMENTS("lines,payments,applied_payments"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_ACCOUNTING_PERIOD("lines,payments,applied_payments,accounting_period"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_COMPANY("lines,payments,applied_payments,company"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD( - "lines,payments,applied_payments,company,accounting_period"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES("lines,payments,applied_payments,tracking_categories"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "lines,payments,applied_payments,tracking_categories,accounting_period"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY( - "lines,payments,applied_payments,tracking_categories,company"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "lines,payments,applied_payments,tracking_categories,company,accounting_period"), - - LINES_PAYMENTS_COMPANY("lines,payments,company"), - - LINES_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("lines,payments,company,accounting_period"), - - LINES_PAYMENTS_TRACKING_CATEGORIES("lines,payments,tracking_categories"), - - LINES_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("lines,payments,tracking_categories,accounting_period"), - - LINES_PAYMENTS_TRACKING_CATEGORIES_COMPANY("lines,payments,tracking_categories,company"), - - LINES_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "lines,payments,tracking_categories,company,accounting_period"), - - LINES_TRACKING_CATEGORIES("lines,tracking_categories"), - - LINES_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("lines,tracking_categories,accounting_period"), - - LINES_TRACKING_CATEGORIES_COMPANY("lines,tracking_categories,company"), - - LINES_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("lines,tracking_categories,company,accounting_period"), - - PAYMENTS("payments"), - - PAYMENTS_ACCOUNTING_PERIOD("payments,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS("payments,applied_payments"), - - PAYMENTS_APPLIED_PAYMENTS_ACCOUNTING_PERIOD("payments,applied_payments,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY("payments,applied_payments,company"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,applied_payments,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES("payments,applied_payments,tracking_categories"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,applied_payments,tracking_categories,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,company,accounting_period"), - - PAYMENTS_COMPANY("payments,company"), - - PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES("payments,tracking_categories"), - - PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("payments,tracking_categories,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,tracking_categories,company"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("payments,tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"); - - private final String value; - - JournalEntriesListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesListRequestExpandItem.java new file mode 100644 index 000000000..f43869560 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesListRequestExpandItem.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.journalentries.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum JournalEntriesListRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + APPLIED_PAYMENTS("applied_payments"), + + COMPANY("company"), + + LINES("lines"), + + PAYMENTS("payments"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + JournalEntriesListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesRetrieveRequestExpand.java deleted file mode 100644 index fead59048..000000000 --- a/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesRetrieveRequestExpand.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.journalentries.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum JournalEntriesRetrieveRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - APPLIED_PAYMENTS("applied_payments"), - - APPLIED_PAYMENTS_ACCOUNTING_PERIOD("applied_payments,accounting_period"), - - APPLIED_PAYMENTS_COMPANY("applied_payments,company"), - - APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("applied_payments,company,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES("applied_payments,tracking_categories"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("applied_payments,tracking_categories,accounting_period"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("applied_payments,tracking_categories,company"), - - APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "applied_payments,tracking_categories,company,accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - LINES("lines"), - - LINES_ACCOUNTING_PERIOD("lines,accounting_period"), - - LINES_APPLIED_PAYMENTS("lines,applied_payments"), - - LINES_APPLIED_PAYMENTS_ACCOUNTING_PERIOD("lines,applied_payments,accounting_period"), - - LINES_APPLIED_PAYMENTS_COMPANY("lines,applied_payments,company"), - - LINES_APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("lines,applied_payments,company,accounting_period"), - - LINES_APPLIED_PAYMENTS_TRACKING_CATEGORIES("lines,applied_payments,tracking_categories"), - - LINES_APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "lines,applied_payments,tracking_categories,accounting_period"), - - LINES_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("lines,applied_payments,tracking_categories,company"), - - LINES_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "lines,applied_payments,tracking_categories,company,accounting_period"), - - LINES_COMPANY("lines,company"), - - LINES_COMPANY_ACCOUNTING_PERIOD("lines,company,accounting_period"), - - LINES_PAYMENTS("lines,payments"), - - LINES_PAYMENTS_ACCOUNTING_PERIOD("lines,payments,accounting_period"), - - LINES_PAYMENTS_APPLIED_PAYMENTS("lines,payments,applied_payments"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_ACCOUNTING_PERIOD("lines,payments,applied_payments,accounting_period"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_COMPANY("lines,payments,applied_payments,company"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD( - "lines,payments,applied_payments,company,accounting_period"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES("lines,payments,applied_payments,tracking_categories"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "lines,payments,applied_payments,tracking_categories,accounting_period"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY( - "lines,payments,applied_payments,tracking_categories,company"), - - LINES_PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "lines,payments,applied_payments,tracking_categories,company,accounting_period"), - - LINES_PAYMENTS_COMPANY("lines,payments,company"), - - LINES_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("lines,payments,company,accounting_period"), - - LINES_PAYMENTS_TRACKING_CATEGORIES("lines,payments,tracking_categories"), - - LINES_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("lines,payments,tracking_categories,accounting_period"), - - LINES_PAYMENTS_TRACKING_CATEGORIES_COMPANY("lines,payments,tracking_categories,company"), - - LINES_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "lines,payments,tracking_categories,company,accounting_period"), - - LINES_TRACKING_CATEGORIES("lines,tracking_categories"), - - LINES_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("lines,tracking_categories,accounting_period"), - - LINES_TRACKING_CATEGORIES_COMPANY("lines,tracking_categories,company"), - - LINES_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("lines,tracking_categories,company,accounting_period"), - - PAYMENTS("payments"), - - PAYMENTS_ACCOUNTING_PERIOD("payments,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS("payments,applied_payments"), - - PAYMENTS_APPLIED_PAYMENTS_ACCOUNTING_PERIOD("payments,applied_payments,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY("payments,applied_payments,company"), - - PAYMENTS_APPLIED_PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,applied_payments,company,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES("payments,applied_payments,tracking_categories"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,accounting_period"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,applied_payments,tracking_categories,company"), - - PAYMENTS_APPLIED_PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "payments,applied_payments,tracking_categories,company,accounting_period"), - - PAYMENTS_COMPANY("payments,company"), - - PAYMENTS_COMPANY_ACCOUNTING_PERIOD("payments,company,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES("payments,tracking_categories"), - - PAYMENTS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("payments,tracking_categories,accounting_period"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY("payments,tracking_categories,company"), - - PAYMENTS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("payments,tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"); - - private final String value; - - JournalEntriesRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesRetrieveRequestExpandItem.java new file mode 100644 index 000000000..e2c0ec0da --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/journalentries/types/JournalEntriesRetrieveRequestExpandItem.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.journalentries.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum JournalEntriesRetrieveRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + APPLIED_PAYMENTS("applied_payments"), + + COMPANY("company"), + + LINES("lines"), + + PAYMENTS("payments"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + JournalEntriesRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/linkedaccounts/AsyncLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/linkedaccounts/AsyncLinkedAccountsClient.java new file mode 100644 index 000000000..bcc5515e8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/linkedaccounts/AsyncLinkedAccountsClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.linkedaccounts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.accounting.types.PaginatedAccountDetailsAndActionsList; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkedAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkedAccountsClient rawClient; + + public AsyncLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkedAccountsClient withRawResponse() { + return this.rawClient; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list(LinkedAccountsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/linkedaccounts/AsyncRawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/linkedaccounts/AsyncRawLinkedAccountsClient.java new file mode 100644 index 000000000..1eeebdbe1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/linkedaccounts/AsyncRawLinkedAccountsClient.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.accounting.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/linkedaccounts/LinkedAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/linkedaccounts/LinkedAccountsClient.java index 54d76fa08..aa5890528 100644 --- a/src/main/java/com/merge/api/resources/accounting/linkedaccounts/LinkedAccountsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/linkedaccounts/LinkedAccountsClient.java @@ -3,40 +3,40 @@ */ package com.merge.api.resources.accounting.linkedaccounts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.linkedaccounts.requests.LinkedAccountsListRequest; import com.merge.api.resources.accounting.types.PaginatedAccountDetailsAndActionsList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkedAccountsClient { protected final ClientOptions clientOptions; + private final RawLinkedAccountsClient rawClient; + public LinkedAccountsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkedAccountsClient withRawResponse() { + return this.rawClient; } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list() { - return list(LinkedAccountsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** @@ -44,80 +44,6 @@ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest requ */ public PaginatedAccountDetailsAndActionsList list( LinkedAccountsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/linked-accounts"); - if (request.getCategory().isPresent()) { - httpUrl.addQueryParameter("category", request.getCategory().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndUserEmailAddress().isPresent()) { - httpUrl.addQueryParameter( - "end_user_email_address", request.getEndUserEmailAddress().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getEndUserOriginId().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_id", request.getEndUserOriginId().get()); - } - if (request.getEndUserOriginIds().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_ids", request.getEndUserOriginIds().get()); - } - if (request.getId().isPresent()) { - httpUrl.addQueryParameter("id", request.getId().get()); - } - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getIncludeDuplicates().isPresent()) { - httpUrl.addQueryParameter( - "include_duplicates", request.getIncludeDuplicates().get().toString()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getIsTestAccount().isPresent()) { - httpUrl.addQueryParameter( - "is_test_account", request.getIsTestAccount().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedAccountDetailsAndActionsList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/linkedaccounts/RawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/accounting/linkedaccounts/RawLinkedAccountsClient.java new file mode 100644 index 000000000..42a30cf8a --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/linkedaccounts/RawLinkedAccountsClient.java @@ -0,0 +1,143 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.accounting.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public RawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list(LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/linktoken/AsyncLinkTokenClient.java b/src/main/java/com/merge/api/resources/accounting/linktoken/AsyncLinkTokenClient.java new file mode 100644 index 000000000..1192f13ba --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/linktoken/AsyncLinkTokenClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.linktoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.accounting.types.LinkToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkTokenClient rawClient; + + public AsyncLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/linktoken/AsyncRawLinkTokenClient.java b/src/main/java/com/merge/api/resources/accounting/linktoken/AsyncRawLinkTokenClient.java new file mode 100644 index 000000000..2ed5f7727 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/linktoken/AsyncRawLinkTokenClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.accounting.types.LinkToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create( + EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/linktoken/LinkTokenClient.java b/src/main/java/com/merge/api/resources/accounting/linktoken/LinkTokenClient.java index c3a471517..09ac72917 100644 --- a/src/main/java/com/merge/api/resources/accounting/linktoken/LinkTokenClient.java +++ b/src/main/java/com/merge/api/resources/accounting/linktoken/LinkTokenClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.accounting.linktoken; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.linktoken.requests.EndUserDetailsRequest; import com.merge.api.resources.accounting.types.LinkToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkTokenClient { protected final ClientOptions clientOptions; + private final RawLinkTokenClient rawClient; + public LinkTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkTokenClient withRawResponse() { + return this.rawClient; } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/link-token") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/linktoken/RawLinkTokenClient.java b/src/main/java/com/merge/api/resources/accounting/linktoken/RawLinkTokenClient.java new file mode 100644 index 000000000..281fcbdc2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/linktoken/RawLinkTokenClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.accounting.types.LinkToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkTokenClient { + protected final ClientOptions clientOptions; + + public RawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/passthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/accounting/passthrough/AsyncPassthroughClient.java new file mode 100644 index 000000000..afa3bd6eb --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/passthrough/AsyncPassthroughClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.passthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.DataPassthroughRequest; +import com.merge.api.resources.accounting.types.RemoteResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPassthroughClient rawClient; + + public AsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/passthrough/AsyncRawPassthroughClient.java b/src/main/java/com/merge/api/resources/accounting/passthrough/AsyncRawPassthroughClient.java new file mode 100644 index 000000000..3dd2a2368 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/passthrough/AsyncRawPassthroughClient.java @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.DataPassthroughRequest; +import com.merge.api.resources.accounting.types.RemoteResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/passthrough/PassthroughClient.java b/src/main/java/com/merge/api/resources/accounting/passthrough/PassthroughClient.java index 053a54d56..20b2e0bc2 100644 --- a/src/main/java/com/merge/api/resources/accounting/passthrough/PassthroughClient.java +++ b/src/main/java/com/merge/api/resources/accounting/passthrough/PassthroughClient.java @@ -3,75 +3,39 @@ */ package com.merge.api.resources.accounting.passthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.types.DataPassthroughRequest; import com.merge.api.resources.accounting.types.RemoteResponse; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PassthroughClient { protected final ClientOptions clientOptions; + private final RawPassthroughClient rawClient; + public PassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPassthroughClient withRawResponse() { + return this.rawClient; } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/passthrough/RawPassthroughClient.java b/src/main/java/com/merge/api/resources/accounting/passthrough/RawPassthroughClient.java new file mode 100644 index 000000000..6ce530631 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/passthrough/RawPassthroughClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.DataPassthroughRequest; +import com.merge.api.resources.accounting.types.RemoteResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPassthroughClient { + protected final ClientOptions clientOptions; + + public RawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentmethods/AsyncPaymentMethodsClient.java b/src/main/java/com/merge/api/resources/accounting/paymentmethods/AsyncPaymentMethodsClient.java new file mode 100644 index 000000000..71e8a291a --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentmethods/AsyncPaymentMethodsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentmethods; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.paymentmethods.requests.PaymentMethodsListRequest; +import com.merge.api.resources.accounting.paymentmethods.requests.PaymentMethodsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedPaymentMethodList; +import com.merge.api.resources.accounting.types.PaymentMethod; +import java.util.concurrent.CompletableFuture; + +public class AsyncPaymentMethodsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPaymentMethodsClient rawClient; + + public AsyncPaymentMethodsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPaymentMethodsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPaymentMethodsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of PaymentMethod objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of PaymentMethod objects. + */ + public CompletableFuture list(PaymentMethodsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of PaymentMethod objects. + */ + public CompletableFuture list( + PaymentMethodsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public CompletableFuture retrieve(String id, PaymentMethodsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public CompletableFuture retrieve( + String id, PaymentMethodsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentmethods/AsyncRawPaymentMethodsClient.java b/src/main/java/com/merge/api/resources/accounting/paymentmethods/AsyncRawPaymentMethodsClient.java new file mode 100644 index 000000000..a10311842 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentmethods/AsyncRawPaymentMethodsClient.java @@ -0,0 +1,209 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentmethods; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.paymentmethods.requests.PaymentMethodsListRequest; +import com.merge.api.resources.accounting.paymentmethods.requests.PaymentMethodsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedPaymentMethodList; +import com.merge.api.resources.accounting.types.PaymentMethod; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPaymentMethodsClient { + protected final ClientOptions clientOptions; + + public AsyncRawPaymentMethodsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of PaymentMethod objects. + */ + public CompletableFuture> list() { + return list(PaymentMethodsListRequest.builder().build()); + } + + /** + * Returns a list of PaymentMethod objects. + */ + public CompletableFuture> list(PaymentMethodsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of PaymentMethod objects. + */ + public CompletableFuture> list( + PaymentMethodsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payment-methods"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedPaymentMethodList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, PaymentMethodsRetrieveRequest.builder().build()); + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public CompletableFuture> retrieve( + String id, PaymentMethodsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public CompletableFuture> retrieve( + String id, PaymentMethodsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payment-methods") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaymentMethod.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentmethods/PaymentMethodsClient.java b/src/main/java/com/merge/api/resources/accounting/paymentmethods/PaymentMethodsClient.java new file mode 100644 index 000000000..6179bc3be --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentmethods/PaymentMethodsClient.java @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentmethods; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.paymentmethods.requests.PaymentMethodsListRequest; +import com.merge.api.resources.accounting.paymentmethods.requests.PaymentMethodsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedPaymentMethodList; +import com.merge.api.resources.accounting.types.PaymentMethod; + +public class PaymentMethodsClient { + protected final ClientOptions clientOptions; + + private final RawPaymentMethodsClient rawClient; + + public PaymentMethodsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawPaymentMethodsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPaymentMethodsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of PaymentMethod objects. + */ + public PaginatedPaymentMethodList list() { + return this.rawClient.list().body(); + } + + /** + * Returns a list of PaymentMethod objects. + */ + public PaginatedPaymentMethodList list(PaymentMethodsListRequest request) { + return this.rawClient.list(request).body(); + } + + /** + * Returns a list of PaymentMethod objects. + */ + public PaginatedPaymentMethodList list(PaymentMethodsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).body(); + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public PaymentMethod retrieve(String id) { + return this.rawClient.retrieve(id).body(); + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public PaymentMethod retrieve(String id, PaymentMethodsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).body(); + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public PaymentMethod retrieve(String id, PaymentMethodsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).body(); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentmethods/RawPaymentMethodsClient.java b/src/main/java/com/merge/api/resources/accounting/paymentmethods/RawPaymentMethodsClient.java new file mode 100644 index 000000000..c293c3a50 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentmethods/RawPaymentMethodsClient.java @@ -0,0 +1,176 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentmethods; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.paymentmethods.requests.PaymentMethodsListRequest; +import com.merge.api.resources.accounting.paymentmethods.requests.PaymentMethodsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedPaymentMethodList; +import com.merge.api.resources.accounting.types.PaymentMethod; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPaymentMethodsClient { + protected final ClientOptions clientOptions; + + public RawPaymentMethodsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of PaymentMethod objects. + */ + public MergeApiHttpResponse list() { + return list(PaymentMethodsListRequest.builder().build()); + } + + /** + * Returns a list of PaymentMethod objects. + */ + public MergeApiHttpResponse list(PaymentMethodsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of PaymentMethod objects. + */ + public MergeApiHttpResponse list( + PaymentMethodsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payment-methods"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPaymentMethodList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, PaymentMethodsRetrieveRequest.builder().build()); + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, PaymentMethodsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a PaymentMethod object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, PaymentMethodsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payment-methods") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaymentMethod.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentmethods/requests/PaymentMethodsListRequest.java b/src/main/java/com/merge/api/resources/accounting/paymentmethods/requests/PaymentMethodsListRequest.java new file mode 100644 index 000000000..aab7380bb --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentmethods/requests/PaymentMethodsListRequest.java @@ -0,0 +1,210 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentmethods.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaymentMethodsListRequest.Builder.class) +public final class PaymentMethodsListRequest { + private final Optional cursor; + + private final Optional includeDeletedData; + + private final Optional includeRemoteData; + + private final Optional includeShellData; + + private final Optional pageSize; + + private final Map additionalProperties; + + private PaymentMethodsListRequest( + Optional cursor, + Optional includeDeletedData, + Optional includeRemoteData, + Optional includeShellData, + Optional pageSize, + Map additionalProperties) { + this.cursor = cursor; + this.includeDeletedData = includeDeletedData; + this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; + this.pageSize = pageSize; + this.additionalProperties = additionalProperties; + } + + /** + * @return The pagination cursor value. + */ + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; + } + + /** + * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. + */ + @JsonProperty("include_deleted_data") + public Optional getIncludeDeletedData() { + return includeDeletedData; + } + + /** + * @return Whether to include the original data Merge fetched from the third-party to produce these models. + */ + @JsonProperty("include_remote_data") + public Optional getIncludeRemoteData() { + return includeRemoteData; + } + + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + + /** + * @return Number of results to return per page. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaymentMethodsListRequest && equalTo((PaymentMethodsListRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaymentMethodsListRequest other) { + return cursor.equals(other.cursor) + && includeDeletedData.equals(other.includeDeletedData) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) + && pageSize.equals(other.pageSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.cursor, this.includeDeletedData, this.includeRemoteData, this.includeShellData, this.pageSize); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional cursor = Optional.empty(); + + private Optional includeDeletedData = Optional.empty(); + + private Optional includeRemoteData = Optional.empty(); + + private Optional includeShellData = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(PaymentMethodsListRequest other) { + cursor(other.getCursor()); + includeDeletedData(other.getIncludeDeletedData()); + includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); + pageSize(other.getPageSize()); + return this; + } + + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); + return this; + } + + @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) + public Builder includeDeletedData(Optional includeDeletedData) { + this.includeDeletedData = includeDeletedData; + return this; + } + + public Builder includeDeletedData(Boolean includeDeletedData) { + this.includeDeletedData = Optional.ofNullable(includeDeletedData); + return this; + } + + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) + public Builder includeRemoteData(Optional includeRemoteData) { + this.includeRemoteData = includeRemoteData; + return this; + } + + public Builder includeRemoteData(Boolean includeRemoteData) { + this.includeRemoteData = Optional.ofNullable(includeRemoteData); + return this; + } + + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) + public Builder pageSize(Optional pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder pageSize(Integer pageSize) { + this.pageSize = Optional.ofNullable(pageSize); + return this; + } + + public PaymentMethodsListRequest build() { + return new PaymentMethodsListRequest( + cursor, includeDeletedData, includeRemoteData, includeShellData, pageSize, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentmethods/requests/PaymentMethodsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/paymentmethods/requests/PaymentMethodsRetrieveRequest.java new file mode 100644 index 000000000..5f702e836 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentmethods/requests/PaymentMethodsRetrieveRequest.java @@ -0,0 +1,126 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentmethods.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaymentMethodsRetrieveRequest.Builder.class) +public final class PaymentMethodsRetrieveRequest { + private final Optional includeRemoteData; + + private final Optional includeShellData; + + private final Map additionalProperties; + + private PaymentMethodsRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { + this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; + this.additionalProperties = additionalProperties; + } + + /** + * @return Whether to include the original data Merge fetched from the third-party to produce these models. + */ + @JsonProperty("include_remote_data") + public Optional getIncludeRemoteData() { + return includeRemoteData; + } + + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaymentMethodsRetrieveRequest && equalTo((PaymentMethodsRetrieveRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaymentMethodsRetrieveRequest other) { + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.includeRemoteData, this.includeShellData); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional includeRemoteData = Optional.empty(); + + private Optional includeShellData = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(PaymentMethodsRetrieveRequest other) { + includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); + return this; + } + + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) + public Builder includeRemoteData(Optional includeRemoteData) { + this.includeRemoteData = includeRemoteData; + return this; + } + + public Builder includeRemoteData(Boolean includeRemoteData) { + this.includeRemoteData = Optional.ofNullable(includeRemoteData); + return this; + } + + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + + public PaymentMethodsRetrieveRequest build() { + return new PaymentMethodsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/payments/AsyncPaymentsClient.java b/src/main/java/com/merge/api/resources/accounting/payments/AsyncPaymentsClient.java new file mode 100644 index 000000000..52dce52d1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/payments/AsyncPaymentsClient.java @@ -0,0 +1,185 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.payments; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.payments.requests.PatchedPaymentEndpointRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentEndpointRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsLineItemsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsListRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsRetrieveRequest; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedPaymentList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.accounting.types.Payment; +import com.merge.api.resources.accounting.types.PaymentResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncPaymentsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPaymentsClient rawClient; + + public AsyncPaymentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPaymentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPaymentsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Payment objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Payment objects. + */ + public CompletableFuture list(PaymentsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Payment objects. + */ + public CompletableFuture list(PaymentsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Payment object with the given values. + */ + public CompletableFuture create(PaymentEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Payment object with the given values. + */ + public CompletableFuture create(PaymentEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Payment object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Payment object with the given id. + */ + public CompletableFuture retrieve(String id, PaymentsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Payment object with the given id. + */ + public CompletableFuture retrieve( + String id, PaymentsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates a Payment object with the given id. + */ + public CompletableFuture partialUpdate(String id, PatchedPaymentEndpointRequest request) { + return this.rawClient.partialUpdate(id, request).thenApply(response -> response.body()); + } + + /** + * Updates a Payment object with the given id. + */ + public CompletableFuture partialUpdate( + String id, PatchedPaymentEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.partialUpdate(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture lineItemsRemoteFieldClassesList() { + return this.rawClient.lineItemsRemoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture lineItemsRemoteFieldClassesList( + PaymentsLineItemsRemoteFieldClassesListRequest request) { + return this.rawClient.lineItemsRemoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture lineItemsRemoteFieldClassesList( + PaymentsLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient + .lineItemsRemoteFieldClassesList(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns metadata for Payment PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id) { + return this.rawClient.metaPatchRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Payment PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id, RequestOptions requestOptions) { + return this.rawClient.metaPatchRetrieve(id, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Payment POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Payment POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + PaymentsRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + PaymentsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/payments/AsyncRawPaymentsClient.java b/src/main/java/com/merge/api/resources/accounting/payments/AsyncRawPaymentsClient.java new file mode 100644 index 000000000..17a388cad --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/payments/AsyncRawPaymentsClient.java @@ -0,0 +1,760 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.payments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.payments.requests.PatchedPaymentEndpointRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentEndpointRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsLineItemsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsListRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsRetrieveRequest; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedPaymentList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.accounting.types.Payment; +import com.merge.api.resources.accounting.types.PaymentResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPaymentsClient { + protected final ClientOptions clientOptions; + + public AsyncRawPaymentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Payment objects. + */ + public CompletableFuture> list() { + return list(PaymentsListRequest.builder().build()); + } + + /** + * Returns a list of Payment objects. + */ + public CompletableFuture> list(PaymentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Payment objects. + */ + public CompletableFuture> list( + PaymentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments"); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getContactId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "contact_id", request.getContactId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPaymentList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Payment object with the given values. + */ + public CompletableFuture> create(PaymentEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Payment object with the given values. + */ + public CompletableFuture> create( + PaymentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaymentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Payment object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, PaymentsRetrieveRequest.builder().build()); + } + + /** + * Returns a Payment object with the given id. + */ + public CompletableFuture> retrieve(String id, PaymentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Payment object with the given id. + */ + public CompletableFuture> retrieve( + String id, PaymentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Payment.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Updates a Payment object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedPaymentEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates a Payment object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedPaymentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaymentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> lineItemsRemoteFieldClassesList() { + return lineItemsRemoteFieldClassesList( + PaymentsLineItemsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> lineItemsRemoteFieldClassesList( + PaymentsLineItemsRemoteFieldClassesListRequest request) { + return lineItemsRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> lineItemsRemoteFieldClassesList( + PaymentsLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments/line-items/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Payment PATCHs. + */ + public CompletableFuture> metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Payment PATCHs. + */ + public CompletableFuture> metaPatchRetrieve( + String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Payment POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Payment POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + PaymentsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + PaymentsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + PaymentsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/payments/PaymentsClient.java b/src/main/java/com/merge/api/resources/accounting/payments/PaymentsClient.java index d921522d6..0f80960eb 100644 --- a/src/main/java/com/merge/api/resources/accounting/payments/PaymentsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/payments/PaymentsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.payments; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.payments.requests.PatchedPaymentEndpointRequest; import com.merge.api.resources.accounting.payments.requests.PaymentEndpointRequest; @@ -20,257 +16,85 @@ import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; import com.merge.api.resources.accounting.types.Payment; import com.merge.api.resources.accounting.types.PaymentResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PaymentsClient { protected final ClientOptions clientOptions; + private final RawPaymentsClient rawClient; + public PaymentsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPaymentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPaymentsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Payment objects. */ public PaginatedPaymentList list() { - return list(PaymentsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Payment objects. */ public PaginatedPaymentList list(PaymentsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Payment objects. */ public PaginatedPaymentList list(PaymentsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/payments"); - if (request.getAccountId().isPresent()) { - httpUrl.addQueryParameter("account_id", request.getAccountId().get()); - } - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getContactId().isPresent()) { - httpUrl.addQueryParameter("contact_id", request.getContactId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getTransactionDateAfter().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_after", - request.getTransactionDateAfter().get().toString()); - } - if (request.getTransactionDateBefore().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_before", - request.getTransactionDateBefore().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPaymentList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Payment object with the given values. */ public PaymentResponse create(PaymentEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Payment object with the given values. */ public PaymentResponse create(PaymentEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/payments"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaymentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Payment object with the given id. */ public Payment retrieve(String id) { - return retrieve(id, PaymentsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Payment object with the given id. */ public Payment retrieve(String id, PaymentsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Payment object with the given id. */ public Payment retrieve(String id, PaymentsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/payments") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Payment.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Updates a Payment object with the given id. */ public PaymentResponse partialUpdate(String id, PatchedPaymentEndpointRequest request) { - return partialUpdate(id, request, null); + return this.rawClient.partialUpdate(id, request).body(); } /** @@ -278,58 +102,14 @@ public PaymentResponse partialUpdate(String id, PatchedPaymentEndpointRequest re */ public PaymentResponse partialUpdate( String id, PatchedPaymentEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/payments") - .addPathSegment(id); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaymentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.partialUpdate(id, request, requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList() { - return lineItemsRemoteFieldClassesList( - PaymentsLineItemsRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.lineItemsRemoteFieldClassesList().body(); } /** @@ -337,7 +117,7 @@ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList() { */ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList( PaymentsLineItemsRemoteFieldClassesListRequest request) { - return lineItemsRemoteFieldClassesList(request, null); + return this.rawClient.lineItemsRemoteFieldClassesList(request).body(); } /** @@ -345,155 +125,51 @@ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList( */ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList( PaymentsLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/payments/line-items/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .lineItemsRemoteFieldClassesList(request, requestOptions) + .body(); } /** * Returns metadata for Payment PATCHs. */ public MetaResponse metaPatchRetrieve(String id) { - return metaPatchRetrieve(id, null); + return this.rawClient.metaPatchRetrieve(id).body(); } /** * Returns metadata for Payment PATCHs. */ public MetaResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/payments/meta/patch") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPatchRetrieve(id, requestOptions).body(); } /** * Returns metadata for Payment POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Payment POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/payments/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - PaymentsRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(PaymentsRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -501,56 +177,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(PaymentsRemoteFieldC */ public PaginatedRemoteFieldClassList remoteFieldClassesList( PaymentsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/payments/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/payments/RawPaymentsClient.java b/src/main/java/com/merge/api/resources/accounting/payments/RawPaymentsClient.java new file mode 100644 index 000000000..95ad2cf04 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/payments/RawPaymentsClient.java @@ -0,0 +1,642 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.payments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.payments.requests.PatchedPaymentEndpointRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentEndpointRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsLineItemsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsListRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.payments.requests.PaymentsRetrieveRequest; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedPaymentList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.accounting.types.Payment; +import com.merge.api.resources.accounting.types.PaymentResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPaymentsClient { + protected final ClientOptions clientOptions; + + public RawPaymentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Payment objects. + */ + public MergeApiHttpResponse list() { + return list(PaymentsListRequest.builder().build()); + } + + /** + * Returns a list of Payment objects. + */ + public MergeApiHttpResponse list(PaymentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Payment objects. + */ + public MergeApiHttpResponse list(PaymentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments"); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getContactId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "contact_id", request.getContactId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPaymentList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Payment object with the given values. + */ + public MergeApiHttpResponse create(PaymentEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Payment object with the given values. + */ + public MergeApiHttpResponse create(PaymentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaymentResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Payment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, PaymentsRetrieveRequest.builder().build()); + } + + /** + * Returns a Payment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, PaymentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Payment object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, PaymentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Payment.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Updates a Payment object with the given id. + */ + public MergeApiHttpResponse partialUpdate(String id, PatchedPaymentEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates a Payment object with the given id. + */ + public MergeApiHttpResponse partialUpdate( + String id, PatchedPaymentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaymentResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse lineItemsRemoteFieldClassesList() { + return lineItemsRemoteFieldClassesList( + PaymentsLineItemsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse lineItemsRemoteFieldClassesList( + PaymentsLineItemsRemoteFieldClassesListRequest request) { + return lineItemsRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse lineItemsRemoteFieldClassesList( + PaymentsLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments/line-items/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Payment PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Payment PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Payment POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Payment POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + PaymentsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + PaymentsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + PaymentsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payments/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/payments/requests/PaymentsListRequest.java b/src/main/java/com/merge/api/resources/accounting/payments/requests/PaymentsListRequest.java index 1f42bf87d..af65b8223 100644 --- a/src/main/java/com/merge/api/resources/accounting/payments/requests/PaymentsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/payments/requests/PaymentsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.payments.types.PaymentsListRequestExpand; +import com.merge.api.resources.accounting.payments.types.PaymentsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = PaymentsListRequest.Builder.class) public final class PaymentsListRequest { + private final Optional> expand; + private final Optional accountId; private final Optional companyId; @@ -34,8 +38,6 @@ public final class PaymentsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -59,13 +61,13 @@ public final class PaymentsListRequest { private final Map additionalProperties; private PaymentsListRequest( + Optional> expand, Optional accountId, Optional companyId, Optional contactId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -77,13 +79,13 @@ private PaymentsListRequest( Optional transactionDateAfter, Optional transactionDateBefore, Map additionalProperties) { + this.expand = expand; this.accountId = accountId; this.companyId = companyId; this.contactId = contactId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -97,6 +99,14 @@ private PaymentsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return payments for this account. */ @@ -145,14 +155,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -245,13 +247,13 @@ public Map getAdditionalProperties() { } private boolean equalTo(PaymentsListRequest other) { - return accountId.equals(other.accountId) + return expand.equals(other.expand) + && accountId.equals(other.accountId) && companyId.equals(other.companyId) && contactId.equals(other.contactId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -267,13 +269,13 @@ private boolean equalTo(PaymentsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.accountId, this.companyId, this.contactId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -297,6 +299,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional accountId = Optional.empty(); private Optional companyId = Optional.empty(); @@ -309,8 +313,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -337,13 +339,13 @@ public static final class Builder { private Builder() {} public Builder from(PaymentsListRequest other) { + expand(other.getExpand()); accountId(other.getAccountId()); companyId(other.getCompanyId()); contactId(other.getContactId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -357,6 +359,22 @@ public Builder from(PaymentsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(PaymentsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "account_id", nulls = Nulls.SKIP) public Builder accountId(Optional accountId) { this.accountId = accountId; @@ -423,17 +441,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(PaymentsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -546,13 +553,13 @@ public Builder transactionDateBefore(OffsetDateTime transactionDateBefore) { public PaymentsListRequest build() { return new PaymentsListRequest( + expand, accountId, companyId, contactId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/accounting/payments/requests/PaymentsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/payments/requests/PaymentsRetrieveRequest.java index 15c7d8a85..0174c15a6 100644 --- a/src/main/java/com/merge/api/resources/accounting/payments/requests/PaymentsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/payments/requests/PaymentsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.payments.types.PaymentsRetrieveRequestExpand; +import com.merge.api.resources.accounting.payments.types.PaymentsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,22 +23,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = PaymentsRetrieveRequest.Builder.class) public final class PaymentsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private PaymentsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -44,7 +50,7 @@ private PaymentsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -64,6 +70,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -78,12 +92,13 @@ public Map getAdditionalProperties() { private boolean equalTo(PaymentsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -97,12 +112,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -112,20 +129,26 @@ public Builder from(PaymentsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(PaymentsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(PaymentsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -148,8 +171,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public PaymentsRetrieveRequest build() { - return new PaymentsRetrieveRequest(expand, includeRemoteData, includeRemoteFields, additionalProperties); + return new PaymentsRetrieveRequest( + expand, includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsListRequestExpand.java deleted file mode 100644 index ad4b0141a..000000000 --- a/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsListRequestExpand.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.payments.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum PaymentsListRequestExpand { - ACCOUNT("account"), - - ACCOUNT_ACCOUNTING_PERIOD("account,accounting_period"), - - ACCOUNT_COMPANY("account,company"), - - ACCOUNT_COMPANY_ACCOUNTING_PERIOD("account,company,accounting_period"), - - ACCOUNTING_PERIOD("accounting_period"), - - APPLIED_TO_LINES("applied_to_lines"), - - APPLIED_TO_LINES_ACCOUNT("applied_to_lines,account"), - - APPLIED_TO_LINES_ACCOUNT_ACCOUNTING_PERIOD("applied_to_lines,account,accounting_period"), - - APPLIED_TO_LINES_ACCOUNT_COMPANY("applied_to_lines,account,company"), - - APPLIED_TO_LINES_ACCOUNT_COMPANY_ACCOUNTING_PERIOD("applied_to_lines,account,company,accounting_period"), - - APPLIED_TO_LINES_ACCOUNTING_PERIOD("applied_to_lines,accounting_period"), - - APPLIED_TO_LINES_COMPANY("applied_to_lines,company"), - - APPLIED_TO_LINES_COMPANY_ACCOUNTING_PERIOD("applied_to_lines,company,accounting_period"), - - APPLIED_TO_LINES_CONTACT("applied_to_lines,contact"), - - APPLIED_TO_LINES_CONTACT_ACCOUNT("applied_to_lines,contact,account"), - - APPLIED_TO_LINES_CONTACT_ACCOUNT_ACCOUNTING_PERIOD("applied_to_lines,contact,account,accounting_period"), - - APPLIED_TO_LINES_CONTACT_ACCOUNT_COMPANY("applied_to_lines,contact,account,company"), - - APPLIED_TO_LINES_CONTACT_ACCOUNT_COMPANY_ACCOUNTING_PERIOD( - "applied_to_lines,contact,account,company,accounting_period"), - - APPLIED_TO_LINES_CONTACT_ACCOUNTING_PERIOD("applied_to_lines,contact,accounting_period"), - - APPLIED_TO_LINES_CONTACT_COMPANY("applied_to_lines,contact,company"), - - APPLIED_TO_LINES_CONTACT_COMPANY_ACCOUNTING_PERIOD("applied_to_lines,contact,company,accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - CONTACT("contact"), - - CONTACT_ACCOUNT("contact,account"), - - CONTACT_ACCOUNT_ACCOUNTING_PERIOD("contact,account,accounting_period"), - - CONTACT_ACCOUNT_COMPANY("contact,account,company"), - - CONTACT_ACCOUNT_COMPANY_ACCOUNTING_PERIOD("contact,account,company,accounting_period"), - - CONTACT_ACCOUNTING_PERIOD("contact,accounting_period"), - - CONTACT_COMPANY("contact,company"), - - CONTACT_COMPANY_ACCOUNTING_PERIOD("contact,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNT("tracking_categories,account"), - - TRACKING_CATEGORIES_ACCOUNT_ACCOUNTING_PERIOD("tracking_categories,account,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY("tracking_categories,account,company"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,account,company,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES("tracking_categories,applied_to_lines"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_ACCOUNT("tracking_categories,applied_to_lines,account"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_ACCOUNT_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,account,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_ACCOUNT_COMPANY("tracking_categories,applied_to_lines,account,company"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_ACCOUNT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,account,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_ACCOUNTING_PERIOD("tracking_categories,applied_to_lines,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_COMPANY("tracking_categories,applied_to_lines,company"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT("tracking_categories,applied_to_lines,contact"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_ACCOUNT("tracking_categories,applied_to_lines,contact,account"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_ACCOUNT_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,contact,account,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_ACCOUNT_COMPANY( - "tracking_categories,applied_to_lines,contact,account,company"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_ACCOUNT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,contact,account,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,contact,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_COMPANY("tracking_categories,applied_to_lines,contact,company"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,contact,company,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_CONTACT("tracking_categories,contact"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT("tracking_categories,contact,account"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT_ACCOUNTING_PERIOD("tracking_categories,contact,account,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT_COMPANY("tracking_categories,contact,account,company"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,contact,account,company,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("tracking_categories,contact,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY("tracking_categories,contact,company"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,contact,company,accounting_period"); - - private final String value; - - PaymentsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsListRequestExpandItem.java new file mode 100644 index 000000000..6298709b8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsListRequestExpandItem.java @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.payments.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PaymentsListRequestExpandItem { + ACCOUNT("account"), + + ACCOUNTING_PERIOD("accounting_period"), + + APPLIED_TO_LINES("applied_to_lines"), + + COMPANY("company"), + + CONTACT("contact"), + + PAYMENT_METHOD("payment_method"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + PaymentsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsRetrieveRequestExpand.java deleted file mode 100644 index ebc5f9912..000000000 --- a/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsRetrieveRequestExpand.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.payments.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum PaymentsRetrieveRequestExpand { - ACCOUNT("account"), - - ACCOUNT_ACCOUNTING_PERIOD("account,accounting_period"), - - ACCOUNT_COMPANY("account,company"), - - ACCOUNT_COMPANY_ACCOUNTING_PERIOD("account,company,accounting_period"), - - ACCOUNTING_PERIOD("accounting_period"), - - APPLIED_TO_LINES("applied_to_lines"), - - APPLIED_TO_LINES_ACCOUNT("applied_to_lines,account"), - - APPLIED_TO_LINES_ACCOUNT_ACCOUNTING_PERIOD("applied_to_lines,account,accounting_period"), - - APPLIED_TO_LINES_ACCOUNT_COMPANY("applied_to_lines,account,company"), - - APPLIED_TO_LINES_ACCOUNT_COMPANY_ACCOUNTING_PERIOD("applied_to_lines,account,company,accounting_period"), - - APPLIED_TO_LINES_ACCOUNTING_PERIOD("applied_to_lines,accounting_period"), - - APPLIED_TO_LINES_COMPANY("applied_to_lines,company"), - - APPLIED_TO_LINES_COMPANY_ACCOUNTING_PERIOD("applied_to_lines,company,accounting_period"), - - APPLIED_TO_LINES_CONTACT("applied_to_lines,contact"), - - APPLIED_TO_LINES_CONTACT_ACCOUNT("applied_to_lines,contact,account"), - - APPLIED_TO_LINES_CONTACT_ACCOUNT_ACCOUNTING_PERIOD("applied_to_lines,contact,account,accounting_period"), - - APPLIED_TO_LINES_CONTACT_ACCOUNT_COMPANY("applied_to_lines,contact,account,company"), - - APPLIED_TO_LINES_CONTACT_ACCOUNT_COMPANY_ACCOUNTING_PERIOD( - "applied_to_lines,contact,account,company,accounting_period"), - - APPLIED_TO_LINES_CONTACT_ACCOUNTING_PERIOD("applied_to_lines,contact,accounting_period"), - - APPLIED_TO_LINES_CONTACT_COMPANY("applied_to_lines,contact,company"), - - APPLIED_TO_LINES_CONTACT_COMPANY_ACCOUNTING_PERIOD("applied_to_lines,contact,company,accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - CONTACT("contact"), - - CONTACT_ACCOUNT("contact,account"), - - CONTACT_ACCOUNT_ACCOUNTING_PERIOD("contact,account,accounting_period"), - - CONTACT_ACCOUNT_COMPANY("contact,account,company"), - - CONTACT_ACCOUNT_COMPANY_ACCOUNTING_PERIOD("contact,account,company,accounting_period"), - - CONTACT_ACCOUNTING_PERIOD("contact,accounting_period"), - - CONTACT_COMPANY("contact,company"), - - CONTACT_COMPANY_ACCOUNTING_PERIOD("contact,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNT("tracking_categories,account"), - - TRACKING_CATEGORIES_ACCOUNT_ACCOUNTING_PERIOD("tracking_categories,account,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY("tracking_categories,account,company"), - - TRACKING_CATEGORIES_ACCOUNT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,account,company,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES("tracking_categories,applied_to_lines"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_ACCOUNT("tracking_categories,applied_to_lines,account"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_ACCOUNT_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,account,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_ACCOUNT_COMPANY("tracking_categories,applied_to_lines,account,company"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_ACCOUNT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,account,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_ACCOUNTING_PERIOD("tracking_categories,applied_to_lines,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_COMPANY("tracking_categories,applied_to_lines,company"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT("tracking_categories,applied_to_lines,contact"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_ACCOUNT("tracking_categories,applied_to_lines,contact,account"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_ACCOUNT_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,contact,account,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_ACCOUNT_COMPANY( - "tracking_categories,applied_to_lines,contact,account,company"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_ACCOUNT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,contact,account,company,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,contact,accounting_period"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_COMPANY("tracking_categories,applied_to_lines,contact,company"), - - TRACKING_CATEGORIES_APPLIED_TO_LINES_CONTACT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,applied_to_lines,contact,company,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_CONTACT("tracking_categories,contact"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT("tracking_categories,contact,account"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT_ACCOUNTING_PERIOD("tracking_categories,contact,account,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT_COMPANY("tracking_categories,contact,account,company"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,contact,account,company,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("tracking_categories,contact,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_COMPANY("tracking_categories,contact,company"), - - TRACKING_CATEGORIES_CONTACT_COMPANY_ACCOUNTING_PERIOD("tracking_categories,contact,company,accounting_period"); - - private final String value; - - PaymentsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..f804b197a --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/payments/types/PaymentsRetrieveRequestExpandItem.java @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.payments.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PaymentsRetrieveRequestExpandItem { + ACCOUNT("account"), + + ACCOUNTING_PERIOD("accounting_period"), + + APPLIED_TO_LINES("applied_to_lines"), + + COMPANY("company"), + + CONTACT("contact"), + + PAYMENT_METHOD("payment_method"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + PaymentsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentterms/AsyncPaymentTermsClient.java b/src/main/java/com/merge/api/resources/accounting/paymentterms/AsyncPaymentTermsClient.java new file mode 100644 index 000000000..0fe6e7afc --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentterms/AsyncPaymentTermsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentterms; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.paymentterms.requests.PaymentTermsListRequest; +import com.merge.api.resources.accounting.paymentterms.requests.PaymentTermsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedPaymentTermList; +import com.merge.api.resources.accounting.types.PaymentTerm; +import java.util.concurrent.CompletableFuture; + +public class AsyncPaymentTermsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPaymentTermsClient rawClient; + + public AsyncPaymentTermsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPaymentTermsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPaymentTermsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of PaymentTerm objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of PaymentTerm objects. + */ + public CompletableFuture list(PaymentTermsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of PaymentTerm objects. + */ + public CompletableFuture list( + PaymentTermsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public CompletableFuture retrieve(String id, PaymentTermsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public CompletableFuture retrieve( + String id, PaymentTermsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentterms/AsyncRawPaymentTermsClient.java b/src/main/java/com/merge/api/resources/accounting/paymentterms/AsyncRawPaymentTermsClient.java new file mode 100644 index 000000000..69373f45f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentterms/AsyncRawPaymentTermsClient.java @@ -0,0 +1,217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentterms; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.paymentterms.requests.PaymentTermsListRequest; +import com.merge.api.resources.accounting.paymentterms.requests.PaymentTermsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedPaymentTermList; +import com.merge.api.resources.accounting.types.PaymentTerm; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPaymentTermsClient { + protected final ClientOptions clientOptions; + + public AsyncRawPaymentTermsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of PaymentTerm objects. + */ + public CompletableFuture> list() { + return list(PaymentTermsListRequest.builder().build()); + } + + /** + * Returns a list of PaymentTerm objects. + */ + public CompletableFuture> list(PaymentTermsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of PaymentTerm objects. + */ + public CompletableFuture> list( + PaymentTermsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payment-terms"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedPaymentTermList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, PaymentTermsRetrieveRequest.builder().build()); + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public CompletableFuture> retrieve( + String id, PaymentTermsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public CompletableFuture> retrieve( + String id, PaymentTermsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payment-terms") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaymentTerm.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentterms/PaymentTermsClient.java b/src/main/java/com/merge/api/resources/accounting/paymentterms/PaymentTermsClient.java new file mode 100644 index 000000000..451856cdb --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentterms/PaymentTermsClient.java @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentterms; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.paymentterms.requests.PaymentTermsListRequest; +import com.merge.api.resources.accounting.paymentterms.requests.PaymentTermsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedPaymentTermList; +import com.merge.api.resources.accounting.types.PaymentTerm; + +public class PaymentTermsClient { + protected final ClientOptions clientOptions; + + private final RawPaymentTermsClient rawClient; + + public PaymentTermsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawPaymentTermsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPaymentTermsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of PaymentTerm objects. + */ + public PaginatedPaymentTermList list() { + return this.rawClient.list().body(); + } + + /** + * Returns a list of PaymentTerm objects. + */ + public PaginatedPaymentTermList list(PaymentTermsListRequest request) { + return this.rawClient.list(request).body(); + } + + /** + * Returns a list of PaymentTerm objects. + */ + public PaginatedPaymentTermList list(PaymentTermsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).body(); + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public PaymentTerm retrieve(String id) { + return this.rawClient.retrieve(id).body(); + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public PaymentTerm retrieve(String id, PaymentTermsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).body(); + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public PaymentTerm retrieve(String id, PaymentTermsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).body(); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentterms/RawPaymentTermsClient.java b/src/main/java/com/merge/api/resources/accounting/paymentterms/RawPaymentTermsClient.java new file mode 100644 index 000000000..392059f5d --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentterms/RawPaymentTermsClient.java @@ -0,0 +1,184 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentterms; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.paymentterms.requests.PaymentTermsListRequest; +import com.merge.api.resources.accounting.paymentterms.requests.PaymentTermsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedPaymentTermList; +import com.merge.api.resources.accounting.types.PaymentTerm; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPaymentTermsClient { + protected final ClientOptions clientOptions; + + public RawPaymentTermsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of PaymentTerm objects. + */ + public MergeApiHttpResponse list() { + return list(PaymentTermsListRequest.builder().build()); + } + + /** + * Returns a list of PaymentTerm objects. + */ + public MergeApiHttpResponse list(PaymentTermsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of PaymentTerm objects. + */ + public MergeApiHttpResponse list( + PaymentTermsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payment-terms"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPaymentTermList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, PaymentTermsRetrieveRequest.builder().build()); + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, PaymentTermsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a PaymentTerm object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, PaymentTermsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/payment-terms") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaymentTerm.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentterms/requests/PaymentTermsListRequest.java b/src/main/java/com/merge/api/resources/accounting/paymentterms/requests/PaymentTermsListRequest.java new file mode 100644 index 000000000..056a500f3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentterms/requests/PaymentTermsListRequest.java @@ -0,0 +1,255 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentterms.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaymentTermsListRequest.Builder.class) +public final class PaymentTermsListRequest { + private final Optional> expand; + + private final Optional cursor; + + private final Optional includeDeletedData; + + private final Optional includeRemoteData; + + private final Optional includeShellData; + + private final Optional pageSize; + + private final Map additionalProperties; + + private PaymentTermsListRequest( + Optional> expand, + Optional cursor, + Optional includeDeletedData, + Optional includeRemoteData, + Optional includeShellData, + Optional pageSize, + Map additionalProperties) { + this.expand = expand; + this.cursor = cursor; + this.includeDeletedData = includeDeletedData; + this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; + this.pageSize = pageSize; + this.additionalProperties = additionalProperties; + } + + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + + /** + * @return The pagination cursor value. + */ + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; + } + + /** + * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. + */ + @JsonProperty("include_deleted_data") + public Optional getIncludeDeletedData() { + return includeDeletedData; + } + + /** + * @return Whether to include the original data Merge fetched from the third-party to produce these models. + */ + @JsonProperty("include_remote_data") + public Optional getIncludeRemoteData() { + return includeRemoteData; + } + + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + + /** + * @return Number of results to return per page. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaymentTermsListRequest && equalTo((PaymentTermsListRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaymentTermsListRequest other) { + return expand.equals(other.expand) + && cursor.equals(other.cursor) + && includeDeletedData.equals(other.includeDeletedData) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) + && pageSize.equals(other.pageSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.expand, + this.cursor, + this.includeDeletedData, + this.includeRemoteData, + this.includeShellData, + this.pageSize); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> expand = Optional.empty(); + + private Optional cursor = Optional.empty(); + + private Optional includeDeletedData = Optional.empty(); + + private Optional includeRemoteData = Optional.empty(); + + private Optional includeShellData = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(PaymentTermsListRequest other) { + expand(other.getExpand()); + cursor(other.getCursor()); + includeDeletedData(other.getIncludeDeletedData()); + includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); + pageSize(other.getPageSize()); + return this; + } + + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); + return this; + } + + @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) + public Builder includeDeletedData(Optional includeDeletedData) { + this.includeDeletedData = includeDeletedData; + return this; + } + + public Builder includeDeletedData(Boolean includeDeletedData) { + this.includeDeletedData = Optional.ofNullable(includeDeletedData); + return this; + } + + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) + public Builder includeRemoteData(Optional includeRemoteData) { + this.includeRemoteData = includeRemoteData; + return this; + } + + public Builder includeRemoteData(Boolean includeRemoteData) { + this.includeRemoteData = Optional.ofNullable(includeRemoteData); + return this; + } + + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) + public Builder pageSize(Optional pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder pageSize(Integer pageSize) { + this.pageSize = Optional.ofNullable(pageSize); + return this; + } + + public PaymentTermsListRequest build() { + return new PaymentTermsListRequest( + expand, + cursor, + includeDeletedData, + includeRemoteData, + includeShellData, + pageSize, + additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/paymentterms/requests/PaymentTermsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/paymentterms/requests/PaymentTermsRetrieveRequest.java new file mode 100644 index 000000000..ed1762150 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/paymentterms/requests/PaymentTermsRetrieveRequest.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.paymentterms.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaymentTermsRetrieveRequest.Builder.class) +public final class PaymentTermsRetrieveRequest { + private final Optional> expand; + + private final Optional includeRemoteData; + + private final Optional includeShellData; + + private final Map additionalProperties; + + private PaymentTermsRetrieveRequest( + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { + this.expand = expand; + this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; + this.additionalProperties = additionalProperties; + } + + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + + /** + * @return Whether to include the original data Merge fetched from the third-party to produce these models. + */ + @JsonProperty("include_remote_data") + public Optional getIncludeRemoteData() { + return includeRemoteData; + } + + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaymentTermsRetrieveRequest && equalTo((PaymentTermsRetrieveRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaymentTermsRetrieveRequest other) { + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> expand = Optional.empty(); + + private Optional includeRemoteData = Optional.empty(); + + private Optional includeShellData = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(PaymentTermsRetrieveRequest other) { + expand(other.getExpand()); + includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); + return this; + } + + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) + public Builder includeRemoteData(Optional includeRemoteData) { + this.includeRemoteData = includeRemoteData; + return this; + } + + public Builder includeRemoteData(Boolean includeRemoteData) { + this.includeRemoteData = Optional.ofNullable(includeRemoteData); + return this; + } + + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + + public PaymentTermsRetrieveRequest build() { + return new PaymentTermsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/phonenumbers/AsyncPhoneNumbersClient.java b/src/main/java/com/merge/api/resources/accounting/phonenumbers/AsyncPhoneNumbersClient.java new file mode 100644 index 000000000..f024561d3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/phonenumbers/AsyncPhoneNumbersClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.phonenumbers; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.phonenumbers.requests.PhoneNumbersRetrieveRequest; +import com.merge.api.resources.accounting.types.AccountingPhoneNumber; +import java.util.concurrent.CompletableFuture; + +public class AsyncPhoneNumbersClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPhoneNumbersClient rawClient; + + public AsyncPhoneNumbersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPhoneNumbersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPhoneNumbersClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns an AccountingPhoneNumber object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an AccountingPhoneNumber object with the given id. + */ + public CompletableFuture retrieve(String id, PhoneNumbersRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an AccountingPhoneNumber object with the given id. + */ + public CompletableFuture retrieve( + String id, PhoneNumbersRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/phonenumbers/AsyncRawPhoneNumbersClient.java b/src/main/java/com/merge/api/resources/accounting/phonenumbers/AsyncRawPhoneNumbersClient.java new file mode 100644 index 000000000..130c74337 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/phonenumbers/AsyncRawPhoneNumbersClient.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.phonenumbers; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.phonenumbers.requests.PhoneNumbersRetrieveRequest; +import com.merge.api.resources.accounting.types.AccountingPhoneNumber; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPhoneNumbersClient { + protected final ClientOptions clientOptions; + + public AsyncRawPhoneNumbersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns an AccountingPhoneNumber object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, PhoneNumbersRetrieveRequest.builder().build()); + } + + /** + * Returns an AccountingPhoneNumber object with the given id. + */ + public CompletableFuture> retrieve( + String id, PhoneNumbersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an AccountingPhoneNumber object with the given id. + */ + public CompletableFuture> retrieve( + String id, PhoneNumbersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/phone-numbers") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingPhoneNumber.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/phonenumbers/PhoneNumbersClient.java b/src/main/java/com/merge/api/resources/accounting/phonenumbers/PhoneNumbersClient.java index 7475f690a..a218c453f 100644 --- a/src/main/java/com/merge/api/resources/accounting/phonenumbers/PhoneNumbersClient.java +++ b/src/main/java/com/merge/api/resources/accounting/phonenumbers/PhoneNumbersClient.java @@ -3,40 +3,40 @@ */ package com.merge.api.resources.accounting.phonenumbers; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.phonenumbers.requests.PhoneNumbersRetrieveRequest; import com.merge.api.resources.accounting.types.AccountingPhoneNumber; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PhoneNumbersClient { protected final ClientOptions clientOptions; + private final RawPhoneNumbersClient rawClient; + public PhoneNumbersClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPhoneNumbersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPhoneNumbersClient withRawResponse() { + return this.rawClient; } /** * Returns an AccountingPhoneNumber object with the given id. */ public AccountingPhoneNumber retrieve(String id) { - return retrieve(id, PhoneNumbersRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an AccountingPhoneNumber object with the given id. */ public AccountingPhoneNumber retrieve(String id, PhoneNumbersRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** @@ -44,37 +44,6 @@ public AccountingPhoneNumber retrieve(String id, PhoneNumbersRetrieveRequest req */ public AccountingPhoneNumber retrieve( String id, PhoneNumbersRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/phone-numbers") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingPhoneNumber.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/phonenumbers/RawPhoneNumbersClient.java b/src/main/java/com/merge/api/resources/accounting/phonenumbers/RawPhoneNumbersClient.java new file mode 100644 index 000000000..c7d53ab54 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/phonenumbers/RawPhoneNumbersClient.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.phonenumbers; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.phonenumbers.requests.PhoneNumbersRetrieveRequest; +import com.merge.api.resources.accounting.types.AccountingPhoneNumber; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPhoneNumbersClient { + protected final ClientOptions clientOptions; + + public RawPhoneNumbersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns an AccountingPhoneNumber object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, PhoneNumbersRetrieveRequest.builder().build()); + } + + /** + * Returns an AccountingPhoneNumber object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, PhoneNumbersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an AccountingPhoneNumber object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, PhoneNumbersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/phone-numbers") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountingPhoneNumber.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/phonenumbers/requests/PhoneNumbersRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/phonenumbers/requests/PhoneNumbersRetrieveRequest.java index 11fb2e3ee..c4055c9da 100644 --- a/src/main/java/com/merge/api/resources/accounting/phonenumbers/requests/PhoneNumbersRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/phonenumbers/requests/PhoneNumbersRetrieveRequest.java @@ -22,10 +22,16 @@ public final class PhoneNumbersRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private PhoneNumbersRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private PhoneNumbersRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(PhoneNumbersRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(PhoneNumbersRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public PhoneNumbersRetrieveRequest build() { - return new PhoneNumbersRetrieveRequest(includeRemoteData, additionalProperties); + return new PhoneNumbersRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/purchaseorders/AsyncPurchaseOrdersClient.java b/src/main/java/com/merge/api/resources/accounting/purchaseorders/AsyncPurchaseOrdersClient.java new file mode 100644 index 000000000..98d8d2c98 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/purchaseorders/AsyncPurchaseOrdersClient.java @@ -0,0 +1,157 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.purchaseorders; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrderEndpointRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersLineItemsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersListRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersRetrieveRequest; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedPurchaseOrderList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.accounting.types.PurchaseOrder; +import com.merge.api.resources.accounting.types.PurchaseOrderResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncPurchaseOrdersClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPurchaseOrdersClient rawClient; + + public AsyncPurchaseOrdersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPurchaseOrdersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPurchaseOrdersClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of PurchaseOrder objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of PurchaseOrder objects. + */ + public CompletableFuture list(PurchaseOrdersListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of PurchaseOrder objects. + */ + public CompletableFuture list( + PurchaseOrdersListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a PurchaseOrder object with the given values. + */ + public CompletableFuture create(PurchaseOrderEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a PurchaseOrder object with the given values. + */ + public CompletableFuture create( + PurchaseOrderEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a PurchaseOrder object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a PurchaseOrder object with the given id. + */ + public CompletableFuture retrieve(String id, PurchaseOrdersRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a PurchaseOrder object with the given id. + */ + public CompletableFuture retrieve( + String id, PurchaseOrdersRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture lineItemsRemoteFieldClassesList() { + return this.rawClient.lineItemsRemoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture lineItemsRemoteFieldClassesList( + PurchaseOrdersLineItemsRemoteFieldClassesListRequest request) { + return this.rawClient.lineItemsRemoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture lineItemsRemoteFieldClassesList( + PurchaseOrdersLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient + .lineItemsRemoteFieldClassesList(request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns metadata for PurchaseOrder POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for PurchaseOrder POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + PurchaseOrdersRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + PurchaseOrdersRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/purchaseorders/AsyncRawPurchaseOrdersClient.java b/src/main/java/com/merge/api/resources/accounting/purchaseorders/AsyncRawPurchaseOrdersClient.java new file mode 100644 index 000000000..a2f8cbc2d --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/purchaseorders/AsyncRawPurchaseOrdersClient.java @@ -0,0 +1,635 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.purchaseorders; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrderEndpointRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersLineItemsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersListRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersRetrieveRequest; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedPurchaseOrderList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.accounting.types.PurchaseOrder; +import com.merge.api.resources.accounting.types.PurchaseOrderResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPurchaseOrdersClient { + protected final ClientOptions clientOptions; + + public AsyncRawPurchaseOrdersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of PurchaseOrder objects. + */ + public CompletableFuture> list() { + return list(PurchaseOrdersListRequest.builder().build()); + } + + /** + * Returns a list of PurchaseOrder objects. + */ + public CompletableFuture> list(PurchaseOrdersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of PurchaseOrder objects. + */ + public CompletableFuture> list( + PurchaseOrdersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIssueDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "issue_date_after", + request.getIssueDateAfter().get().toString(), + false); + } + if (request.getIssueDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "issue_date_before", + request.getIssueDateBefore().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedPurchaseOrderList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a PurchaseOrder object with the given values. + */ + public CompletableFuture> create(PurchaseOrderEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a PurchaseOrder object with the given values. + */ + public CompletableFuture> create( + PurchaseOrderEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PurchaseOrderResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a PurchaseOrder object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, PurchaseOrdersRetrieveRequest.builder().build()); + } + + /** + * Returns a PurchaseOrder object with the given id. + */ + public CompletableFuture> retrieve( + String id, PurchaseOrdersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a PurchaseOrder object with the given id. + */ + public CompletableFuture> retrieve( + String id, PurchaseOrdersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PurchaseOrder.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> lineItemsRemoteFieldClassesList() { + return lineItemsRemoteFieldClassesList( + PurchaseOrdersLineItemsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> lineItemsRemoteFieldClassesList( + PurchaseOrdersLineItemsRemoteFieldClassesListRequest request) { + return lineItemsRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> lineItemsRemoteFieldClassesList( + PurchaseOrdersLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders/line-items/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for PurchaseOrder POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for PurchaseOrder POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + PurchaseOrdersRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + PurchaseOrdersRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + PurchaseOrdersRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/purchaseorders/PurchaseOrdersClient.java b/src/main/java/com/merge/api/resources/accounting/purchaseorders/PurchaseOrdersClient.java index 51595349d..34824972b 100644 --- a/src/main/java/com/merge/api/resources/accounting/purchaseorders/PurchaseOrdersClient.java +++ b/src/main/java/com/merge/api/resources/accounting/purchaseorders/PurchaseOrdersClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.purchaseorders; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrderEndpointRequest; import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersLineItemsRemoteFieldClassesListRequest; @@ -19,264 +15,85 @@ import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; import com.merge.api.resources.accounting.types.PurchaseOrder; import com.merge.api.resources.accounting.types.PurchaseOrderResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PurchaseOrdersClient { protected final ClientOptions clientOptions; + private final RawPurchaseOrdersClient rawClient; + public PurchaseOrdersClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPurchaseOrdersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPurchaseOrdersClient withRawResponse() { + return this.rawClient; } /** * Returns a list of PurchaseOrder objects. */ public PaginatedPurchaseOrderList list() { - return list(PurchaseOrdersListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of PurchaseOrder objects. */ public PaginatedPurchaseOrderList list(PurchaseOrdersListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of PurchaseOrder objects. */ public PaginatedPurchaseOrderList list(PurchaseOrdersListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/purchase-orders"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIssueDateAfter().isPresent()) { - httpUrl.addQueryParameter( - "issue_date_after", request.getIssueDateAfter().get().toString()); - } - if (request.getIssueDateBefore().isPresent()) { - httpUrl.addQueryParameter( - "issue_date_before", request.getIssueDateBefore().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPurchaseOrderList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a PurchaseOrder object with the given values. */ public PurchaseOrderResponse create(PurchaseOrderEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a PurchaseOrder object with the given values. */ public PurchaseOrderResponse create(PurchaseOrderEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/purchase-orders"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PurchaseOrderResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a PurchaseOrder object with the given id. */ public PurchaseOrder retrieve(String id) { - return retrieve(id, PurchaseOrdersRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a PurchaseOrder object with the given id. */ public PurchaseOrder retrieve(String id, PurchaseOrdersRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a PurchaseOrder object with the given id. */ public PurchaseOrder retrieve(String id, PurchaseOrdersRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/purchase-orders") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PurchaseOrder.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList() { - return lineItemsRemoteFieldClassesList( - PurchaseOrdersLineItemsRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.lineItemsRemoteFieldClassesList().body(); } /** @@ -284,7 +101,7 @@ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList() { */ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList( PurchaseOrdersLineItemsRemoteFieldClassesListRequest request) { - return lineItemsRemoteFieldClassesList(request, null); + return this.rawClient.lineItemsRemoteFieldClassesList(request).body(); } /** @@ -292,113 +109,37 @@ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList( */ public PaginatedRemoteFieldClassList lineItemsRemoteFieldClassesList( PurchaseOrdersLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/purchase-orders/line-items/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .lineItemsRemoteFieldClassesList(request, requestOptions) + .body(); } /** * Returns metadata for PurchaseOrder POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for PurchaseOrder POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/purchase-orders/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - PurchaseOrdersRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(PurchaseOrdersRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -406,56 +147,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(PurchaseOrdersRemote */ public PaginatedRemoteFieldClassList remoteFieldClassesList( PurchaseOrdersRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/purchase-orders/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/purchaseorders/RawPurchaseOrdersClient.java b/src/main/java/com/merge/api/resources/accounting/purchaseorders/RawPurchaseOrdersClient.java new file mode 100644 index 000000000..e845ac07c --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/purchaseorders/RawPurchaseOrdersClient.java @@ -0,0 +1,547 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.purchaseorders; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrderEndpointRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersLineItemsRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersListRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersRemoteFieldClassesListRequest; +import com.merge.api.resources.accounting.purchaseorders.requests.PurchaseOrdersRetrieveRequest; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedPurchaseOrderList; +import com.merge.api.resources.accounting.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.accounting.types.PurchaseOrder; +import com.merge.api.resources.accounting.types.PurchaseOrderResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPurchaseOrdersClient { + protected final ClientOptions clientOptions; + + public RawPurchaseOrdersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of PurchaseOrder objects. + */ + public MergeApiHttpResponse list() { + return list(PurchaseOrdersListRequest.builder().build()); + } + + /** + * Returns a list of PurchaseOrder objects. + */ + public MergeApiHttpResponse list(PurchaseOrdersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of PurchaseOrder objects. + */ + public MergeApiHttpResponse list( + PurchaseOrdersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIssueDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "issue_date_after", + request.getIssueDateAfter().get().toString(), + false); + } + if (request.getIssueDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "issue_date_before", + request.getIssueDateBefore().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPurchaseOrderList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a PurchaseOrder object with the given values. + */ + public MergeApiHttpResponse create(PurchaseOrderEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a PurchaseOrder object with the given values. + */ + public MergeApiHttpResponse create( + PurchaseOrderEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PurchaseOrderResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a PurchaseOrder object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, PurchaseOrdersRetrieveRequest.builder().build()); + } + + /** + * Returns a PurchaseOrder object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, PurchaseOrdersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a PurchaseOrder object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, PurchaseOrdersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PurchaseOrder.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse lineItemsRemoteFieldClassesList() { + return lineItemsRemoteFieldClassesList( + PurchaseOrdersLineItemsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse lineItemsRemoteFieldClassesList( + PurchaseOrdersLineItemsRemoteFieldClassesListRequest request) { + return lineItemsRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse lineItemsRemoteFieldClassesList( + PurchaseOrdersLineItemsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders/line-items/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for PurchaseOrder POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for PurchaseOrder POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + PurchaseOrdersRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + PurchaseOrdersRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + PurchaseOrdersRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/purchase-orders/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/purchaseorders/requests/PurchaseOrdersListRequest.java b/src/main/java/com/merge/api/resources/accounting/purchaseorders/requests/PurchaseOrdersListRequest.java index 9d12d1884..a50a29a7b 100644 --- a/src/main/java/com/merge/api/resources/accounting/purchaseorders/requests/PurchaseOrdersListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/purchaseorders/requests/PurchaseOrdersListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.purchaseorders.types.PurchaseOrdersListRequestExpand; +import com.merge.api.resources.accounting.purchaseorders.types.PurchaseOrdersListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = PurchaseOrdersListRequest.Builder.class) public final class PurchaseOrdersListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -30,8 +34,6 @@ public final class PurchaseOrdersListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -59,11 +61,11 @@ public final class PurchaseOrdersListRequest { private final Map additionalProperties; private PurchaseOrdersListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -77,11 +79,11 @@ private PurchaseOrdersListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -97,6 +99,14 @@ private PurchaseOrdersListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return purchase orders for this company. */ @@ -129,14 +139,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -245,11 +247,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(PurchaseOrdersListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -267,11 +269,11 @@ private boolean equalTo(PurchaseOrdersListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -297,6 +299,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -305,8 +309,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -337,11 +339,11 @@ public static final class Builder { private Builder() {} public Builder from(PurchaseOrdersListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -357,6 +359,22 @@ public Builder from(PurchaseOrdersListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(PurchaseOrdersListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -401,17 +419,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(PurchaseOrdersListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -546,11 +553,11 @@ public Builder showEnumOrigins(String showEnumOrigins) { public PurchaseOrdersListRequest build() { return new PurchaseOrdersListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/accounting/purchaseorders/requests/PurchaseOrdersRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/purchaseorders/requests/PurchaseOrdersRetrieveRequest.java index 30e23e69c..dbc85bf66 100644 --- a/src/main/java/com/merge/api/resources/accounting/purchaseorders/requests/PurchaseOrdersRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/purchaseorders/requests/PurchaseOrdersRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.purchaseorders.types.PurchaseOrdersRetrieveRequestExpand; +import com.merge.api.resources.accounting.purchaseorders.types.PurchaseOrdersRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,12 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = PurchaseOrdersRetrieveRequest.Builder.class) public final class PurchaseOrdersRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -34,15 +38,17 @@ public final class PurchaseOrdersRetrieveRequest { private final Map additionalProperties; private PurchaseOrdersRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -52,7 +58,7 @@ private PurchaseOrdersRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -72,6 +78,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -103,6 +117,7 @@ private boolean equalTo(PurchaseOrdersRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @@ -110,7 +125,12 @@ private boolean equalTo(PurchaseOrdersRetrieveRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.expand, this.includeRemoteData, this.includeRemoteFields, this.remoteFields, this.showEnumOrigins); + this.expand, + this.includeRemoteData, + this.includeRemoteFields, + this.includeShellData, + this.remoteFields, + this.showEnumOrigins); } @java.lang.Override @@ -124,12 +144,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -143,22 +165,28 @@ public Builder from(PurchaseOrdersRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(PurchaseOrdersRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(PurchaseOrdersRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -181,6 +209,17 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -208,6 +247,7 @@ public PurchaseOrdersRetrieveRequest build() { expand, includeRemoteData, includeRemoteFields, + includeShellData, remoteFields, showEnumOrigins, additionalProperties); diff --git a/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersListRequestExpand.java deleted file mode 100644 index f8d55ecbf..000000000 --- a/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersListRequestExpand.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.purchaseorders.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum PurchaseOrdersListRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - DELIVERY_ADDRESS("delivery_address"), - - DELIVERY_ADDRESS_ACCOUNTING_PERIOD("delivery_address,accounting_period"), - - DELIVERY_ADDRESS_COMPANY("delivery_address,company"), - - DELIVERY_ADDRESS_COMPANY_ACCOUNTING_PERIOD("delivery_address,company,accounting_period"), - - DELIVERY_ADDRESS_VENDOR("delivery_address,vendor"), - - DELIVERY_ADDRESS_VENDOR_ACCOUNTING_PERIOD("delivery_address,vendor,accounting_period"), - - DELIVERY_ADDRESS_VENDOR_COMPANY("delivery_address,vendor,company"), - - DELIVERY_ADDRESS_VENDOR_COMPANY_ACCOUNTING_PERIOD("delivery_address,vendor,company,accounting_period"), - - LINE_ITEMS("line_items"), - - LINE_ITEMS_ACCOUNTING_PERIOD("line_items,accounting_period"), - - LINE_ITEMS_COMPANY("line_items,company"), - - LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("line_items,company,accounting_period"), - - LINE_ITEMS_DELIVERY_ADDRESS("line_items,delivery_address"), - - LINE_ITEMS_DELIVERY_ADDRESS_ACCOUNTING_PERIOD("line_items,delivery_address,accounting_period"), - - LINE_ITEMS_DELIVERY_ADDRESS_COMPANY("line_items,delivery_address,company"), - - LINE_ITEMS_DELIVERY_ADDRESS_COMPANY_ACCOUNTING_PERIOD("line_items,delivery_address,company,accounting_period"), - - LINE_ITEMS_DELIVERY_ADDRESS_VENDOR("line_items,delivery_address,vendor"), - - LINE_ITEMS_DELIVERY_ADDRESS_VENDOR_ACCOUNTING_PERIOD("line_items,delivery_address,vendor,accounting_period"), - - LINE_ITEMS_DELIVERY_ADDRESS_VENDOR_COMPANY("line_items,delivery_address,vendor,company"), - - LINE_ITEMS_DELIVERY_ADDRESS_VENDOR_COMPANY_ACCOUNTING_PERIOD( - "line_items,delivery_address,vendor,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES("line_items,tracking_categories"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("line_items,tracking_categories,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("line_items,tracking_categories,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS("line_items,tracking_categories,delivery_address"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,delivery_address,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_COMPANY("line_items,tracking_categories,delivery_address,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,delivery_address,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR("line_items,tracking_categories,delivery_address,vendor"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_ACCOUNTING_PERIOD( - "line_items,tracking_categories,delivery_address,vendor,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_COMPANY( - "line_items,tracking_categories,delivery_address,vendor,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,delivery_address,vendor,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_VENDOR("line_items,tracking_categories,vendor"), - - LINE_ITEMS_TRACKING_CATEGORIES_VENDOR_ACCOUNTING_PERIOD("line_items,tracking_categories,vendor,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_VENDOR_COMPANY("line_items,tracking_categories,vendor,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_VENDOR_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,vendor,company,accounting_period"), - - LINE_ITEMS_VENDOR("line_items,vendor"), - - LINE_ITEMS_VENDOR_ACCOUNTING_PERIOD("line_items,vendor,accounting_period"), - - LINE_ITEMS_VENDOR_COMPANY("line_items,vendor,company"), - - LINE_ITEMS_VENDOR_COMPANY_ACCOUNTING_PERIOD("line_items,vendor,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS("tracking_categories,delivery_address"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_ACCOUNTING_PERIOD("tracking_categories,delivery_address,accounting_period"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_COMPANY("tracking_categories,delivery_address,company"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,delivery_address,company,accounting_period"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR("tracking_categories,delivery_address,vendor"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_ACCOUNTING_PERIOD( - "tracking_categories,delivery_address,vendor,accounting_period"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_COMPANY("tracking_categories,delivery_address,vendor,company"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,delivery_address,vendor,company,accounting_period"), - - TRACKING_CATEGORIES_VENDOR("tracking_categories,vendor"), - - TRACKING_CATEGORIES_VENDOR_ACCOUNTING_PERIOD("tracking_categories,vendor,accounting_period"), - - TRACKING_CATEGORIES_VENDOR_COMPANY("tracking_categories,vendor,company"), - - TRACKING_CATEGORIES_VENDOR_COMPANY_ACCOUNTING_PERIOD("tracking_categories,vendor,company,accounting_period"), - - VENDOR("vendor"), - - VENDOR_ACCOUNTING_PERIOD("vendor,accounting_period"), - - VENDOR_COMPANY("vendor,company"), - - VENDOR_COMPANY_ACCOUNTING_PERIOD("vendor,company,accounting_period"); - - private final String value; - - PurchaseOrdersListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersListRequestExpandItem.java new file mode 100644 index 000000000..7fae79c5f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersListRequestExpandItem.java @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.purchaseorders.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PurchaseOrdersListRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + COMPANY("company"), + + DELIVERY_ADDRESS("delivery_address"), + + LINE_ITEMS("line_items"), + + PAYMENT_TERM("payment_term"), + + TRACKING_CATEGORIES("tracking_categories"), + + VENDOR("vendor"); + + private final String value; + + PurchaseOrdersListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersRetrieveRequestExpand.java deleted file mode 100644 index 664dadb64..000000000 --- a/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersRetrieveRequestExpand.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.purchaseorders.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum PurchaseOrdersRetrieveRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - DELIVERY_ADDRESS("delivery_address"), - - DELIVERY_ADDRESS_ACCOUNTING_PERIOD("delivery_address,accounting_period"), - - DELIVERY_ADDRESS_COMPANY("delivery_address,company"), - - DELIVERY_ADDRESS_COMPANY_ACCOUNTING_PERIOD("delivery_address,company,accounting_period"), - - DELIVERY_ADDRESS_VENDOR("delivery_address,vendor"), - - DELIVERY_ADDRESS_VENDOR_ACCOUNTING_PERIOD("delivery_address,vendor,accounting_period"), - - DELIVERY_ADDRESS_VENDOR_COMPANY("delivery_address,vendor,company"), - - DELIVERY_ADDRESS_VENDOR_COMPANY_ACCOUNTING_PERIOD("delivery_address,vendor,company,accounting_period"), - - LINE_ITEMS("line_items"), - - LINE_ITEMS_ACCOUNTING_PERIOD("line_items,accounting_period"), - - LINE_ITEMS_COMPANY("line_items,company"), - - LINE_ITEMS_COMPANY_ACCOUNTING_PERIOD("line_items,company,accounting_period"), - - LINE_ITEMS_DELIVERY_ADDRESS("line_items,delivery_address"), - - LINE_ITEMS_DELIVERY_ADDRESS_ACCOUNTING_PERIOD("line_items,delivery_address,accounting_period"), - - LINE_ITEMS_DELIVERY_ADDRESS_COMPANY("line_items,delivery_address,company"), - - LINE_ITEMS_DELIVERY_ADDRESS_COMPANY_ACCOUNTING_PERIOD("line_items,delivery_address,company,accounting_period"), - - LINE_ITEMS_DELIVERY_ADDRESS_VENDOR("line_items,delivery_address,vendor"), - - LINE_ITEMS_DELIVERY_ADDRESS_VENDOR_ACCOUNTING_PERIOD("line_items,delivery_address,vendor,accounting_period"), - - LINE_ITEMS_DELIVERY_ADDRESS_VENDOR_COMPANY("line_items,delivery_address,vendor,company"), - - LINE_ITEMS_DELIVERY_ADDRESS_VENDOR_COMPANY_ACCOUNTING_PERIOD( - "line_items,delivery_address,vendor,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES("line_items,tracking_categories"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("line_items,tracking_categories,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY("line_items,tracking_categories,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS("line_items,tracking_categories,delivery_address"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_ACCOUNTING_PERIOD( - "line_items,tracking_categories,delivery_address,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_COMPANY("line_items,tracking_categories,delivery_address,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,delivery_address,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR("line_items,tracking_categories,delivery_address,vendor"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_ACCOUNTING_PERIOD( - "line_items,tracking_categories,delivery_address,vendor,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_COMPANY( - "line_items,tracking_categories,delivery_address,vendor,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,delivery_address,vendor,company,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_VENDOR("line_items,tracking_categories,vendor"), - - LINE_ITEMS_TRACKING_CATEGORIES_VENDOR_ACCOUNTING_PERIOD("line_items,tracking_categories,vendor,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_VENDOR_COMPANY("line_items,tracking_categories,vendor,company"), - - LINE_ITEMS_TRACKING_CATEGORIES_VENDOR_COMPANY_ACCOUNTING_PERIOD( - "line_items,tracking_categories,vendor,company,accounting_period"), - - LINE_ITEMS_VENDOR("line_items,vendor"), - - LINE_ITEMS_VENDOR_ACCOUNTING_PERIOD("line_items,vendor,accounting_period"), - - LINE_ITEMS_VENDOR_COMPANY("line_items,vendor,company"), - - LINE_ITEMS_VENDOR_COMPANY_ACCOUNTING_PERIOD("line_items,vendor,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS("tracking_categories,delivery_address"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_ACCOUNTING_PERIOD("tracking_categories,delivery_address,accounting_period"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_COMPANY("tracking_categories,delivery_address,company"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,delivery_address,company,accounting_period"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR("tracking_categories,delivery_address,vendor"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_ACCOUNTING_PERIOD( - "tracking_categories,delivery_address,vendor,accounting_period"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_COMPANY("tracking_categories,delivery_address,vendor,company"), - - TRACKING_CATEGORIES_DELIVERY_ADDRESS_VENDOR_COMPANY_ACCOUNTING_PERIOD( - "tracking_categories,delivery_address,vendor,company,accounting_period"), - - TRACKING_CATEGORIES_VENDOR("tracking_categories,vendor"), - - TRACKING_CATEGORIES_VENDOR_ACCOUNTING_PERIOD("tracking_categories,vendor,accounting_period"), - - TRACKING_CATEGORIES_VENDOR_COMPANY("tracking_categories,vendor,company"), - - TRACKING_CATEGORIES_VENDOR_COMPANY_ACCOUNTING_PERIOD("tracking_categories,vendor,company,accounting_period"), - - VENDOR("vendor"), - - VENDOR_ACCOUNTING_PERIOD("vendor,accounting_period"), - - VENDOR_COMPANY("vendor,company"), - - VENDOR_COMPANY_ACCOUNTING_PERIOD("vendor,company,accounting_period"); - - private final String value; - - PurchaseOrdersRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersRetrieveRequestExpandItem.java new file mode 100644 index 000000000..c0a06f37d --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/purchaseorders/types/PurchaseOrdersRetrieveRequestExpandItem.java @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.purchaseorders.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum PurchaseOrdersRetrieveRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + COMPANY("company"), + + DELIVERY_ADDRESS("delivery_address"), + + LINE_ITEMS("line_items"), + + PAYMENT_TERM("payment_term"), + + TRACKING_CATEGORIES("tracking_categories"), + + VENDOR("vendor"); + + private final String value; + + PurchaseOrdersRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/regeneratekey/AsyncRawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/accounting/regeneratekey/AsyncRawRegenerateKeyClient.java new file mode 100644 index 000000000..bd59b7ada --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/regeneratekey/AsyncRawRegenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.accounting.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/regeneratekey/AsyncRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/accounting/regeneratekey/AsyncRegenerateKeyClient.java new file mode 100644 index 000000000..d1e50962d --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/regeneratekey/AsyncRegenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.regeneratekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.accounting.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncRegenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawRegenerateKeyClient rawClient; + + public AsyncRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawRegenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/regeneratekey/RawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/accounting/regeneratekey/RawRegenerateKeyClient.java new file mode 100644 index 000000000..69fc0d194 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/regeneratekey/RawRegenerateKeyClient.java @@ -0,0 +1,82 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.accounting.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/regeneratekey/RegenerateKeyClient.java b/src/main/java/com/merge/api/resources/accounting/regeneratekey/RegenerateKeyClient.java index f599650e1..bb3dd2bf3 100644 --- a/src/main/java/com/merge/api/resources/accounting/regeneratekey/RegenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/accounting/regeneratekey/RegenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.accounting.regeneratekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.regeneratekey.requests.RemoteKeyForRegenerationRequest; import com.merge.api.resources.accounting.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class RegenerateKeyClient { protected final ClientOptions clientOptions; + private final RawRegenerateKeyClient rawClient; + public RegenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawRegenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/regenerate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/scopes/AsyncRawScopesClient.java b/src/main/java/com/merge/api/resources/accounting/scopes/AsyncRawScopesClient.java new file mode 100644 index 000000000..39e566532 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/scopes/AsyncRawScopesClient.java @@ -0,0 +1,217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.accounting.types.CommonModelScopeApi; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawScopesClient { + protected final ClientOptions clientOptions; + + public AsyncRawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/scopes/AsyncScopesClient.java b/src/main/java/com/merge/api/resources/accounting/scopes/AsyncScopesClient.java new file mode 100644 index 000000000..7d461d07a --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/scopes/AsyncScopesClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.scopes; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.accounting.types.CommonModelScopeApi; +import java.util.concurrent.CompletableFuture; + +public class AsyncScopesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawScopesClient rawClient; + + public AsyncScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawScopesClient withRawResponse() { + return this.rawClient; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve() { + return this.rawClient.defaultScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.defaultScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve() { + return this.rawClient.linkedAccountScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return this.rawClient.linkedAccountScopesCreate(request).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/scopes/RawScopesClient.java b/src/main/java/com/merge/api/resources/accounting/scopes/RawScopesClient.java new file mode 100644 index 000000000..b6b4cf82f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/scopes/RawScopesClient.java @@ -0,0 +1,172 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.accounting.types.CommonModelScopeApi; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawScopesClient { + protected final ClientOptions clientOptions; + + public RawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/scopes/ScopesClient.java b/src/main/java/com/merge/api/resources/accounting/scopes/ScopesClient.java index 7d46051ff..fe9d0cdf7 100644 --- a/src/main/java/com/merge/api/resources/accounting/scopes/ScopesClient.java +++ b/src/main/java/com/merge/api/resources/accounting/scopes/ScopesClient.java @@ -3,118 +3,61 @@ */ package com.merge.api.resources.accounting.scopes; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; import com.merge.api.resources.accounting.types.CommonModelScopeApi; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ScopesClient { protected final ClientOptions clientOptions; + private final RawScopesClient rawClient; + public ScopesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawScopesClient withRawResponse() { + return this.rawClient; } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve() { - return defaultScopesRetrieve(null); + return this.rawClient.defaultScopesRetrieve().body(); } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/default-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.defaultScopesRetrieve(requestOptions).body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve() { - return linkedAccountScopesRetrieve(null); + return this.rawClient.linkedAccountScopesRetrieve().body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/linked-account-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).body(); } /** * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more */ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelScopeDeserializerRequest request) { - return linkedAccountScopesCreate(request, null); + return this.rawClient.linkedAccountScopesCreate(request).body(); } /** @@ -122,40 +65,6 @@ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelSco */ public CommonModelScopeApi linkedAccountScopesCreate( LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/linked-account-scopes") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/syncstatus/AsyncRawSyncStatusClient.java b/src/main/java/com/merge/api/resources/accounting/syncstatus/AsyncRawSyncStatusClient.java new file mode 100644 index 000000000..8a01bbfe9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/syncstatus/AsyncRawSyncStatusClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.accounting.types.PaginatedSyncStatusList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawSyncStatusClient { + protected final ClientOptions clientOptions; + + public AsyncRawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedSyncStatusList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/syncstatus/AsyncSyncStatusClient.java b/src/main/java/com/merge/api/resources/accounting/syncstatus/AsyncSyncStatusClient.java new file mode 100644 index 000000000..57f143a63 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/syncstatus/AsyncSyncStatusClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.syncstatus; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.accounting.types.PaginatedSyncStatusList; +import java.util.concurrent.CompletableFuture; + +public class AsyncSyncStatusClient { + protected final ClientOptions clientOptions; + + private final AsyncRawSyncStatusClient rawClient; + + public AsyncSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawSyncStatusClient withRawResponse() { + return this.rawClient; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list(SyncStatusListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list( + SyncStatusListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/syncstatus/RawSyncStatusClient.java b/src/main/java/com/merge/api/resources/accounting/syncstatus/RawSyncStatusClient.java new file mode 100644 index 000000000..f83cf25ba --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/syncstatus/RawSyncStatusClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.accounting.types.PaginatedSyncStatusList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawSyncStatusClient { + protected final ClientOptions clientOptions; + + public RawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/syncstatus/SyncStatusClient.java b/src/main/java/com/merge/api/resources/accounting/syncstatus/SyncStatusClient.java index e7c72bf3c..a4e91d6f4 100644 --- a/src/main/java/com/merge/api/resources/accounting/syncstatus/SyncStatusClient.java +++ b/src/main/java/com/merge/api/resources/accounting/syncstatus/SyncStatusClient.java @@ -3,78 +3,46 @@ */ package com.merge.api.resources.accounting.syncstatus; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.syncstatus.requests.SyncStatusListRequest; import com.merge.api.resources.accounting.types.PaginatedSyncStatusList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class SyncStatusClient { protected final ClientOptions clientOptions; + private final RawSyncStatusClient rawClient; + public SyncStatusClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawSyncStatusClient withRawResponse() { + return this.rawClient; } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list() { - return list(SyncStatusListRequest.builder().build()); + return this.rawClient.list().body(); } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/sync-status"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/taxrates/AsyncRawTaxRatesClient.java b/src/main/java/com/merge/api/resources/accounting/taxrates/AsyncRawTaxRatesClient.java new file mode 100644 index 000000000..17b3a0a5f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/taxrates/AsyncRawTaxRatesClient.java @@ -0,0 +1,245 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.taxrates; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.taxrates.requests.TaxRatesListRequest; +import com.merge.api.resources.accounting.taxrates.requests.TaxRatesRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedTaxRateList; +import com.merge.api.resources.accounting.types.TaxRate; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTaxRatesClient { + protected final ClientOptions clientOptions; + + public AsyncRawTaxRatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of TaxRate objects. + */ + public CompletableFuture> list() { + return list(TaxRatesListRequest.builder().build()); + } + + /** + * Returns a list of TaxRate objects. + */ + public CompletableFuture> list(TaxRatesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of TaxRate objects. + */ + public CompletableFuture> list( + TaxRatesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/tax-rates"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTaxRateList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a TaxRate object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TaxRatesRetrieveRequest.builder().build()); + } + + /** + * Returns a TaxRate object with the given id. + */ + public CompletableFuture> retrieve(String id, TaxRatesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a TaxRate object with the given id. + */ + public CompletableFuture> retrieve( + String id, TaxRatesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/tax-rates") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TaxRate.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/taxrates/AsyncTaxRatesClient.java b/src/main/java/com/merge/api/resources/accounting/taxrates/AsyncTaxRatesClient.java new file mode 100644 index 000000000..7e72d9b04 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/taxrates/AsyncTaxRatesClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.taxrates; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.taxrates.requests.TaxRatesListRequest; +import com.merge.api.resources.accounting.taxrates.requests.TaxRatesRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedTaxRateList; +import com.merge.api.resources.accounting.types.TaxRate; +import java.util.concurrent.CompletableFuture; + +public class AsyncTaxRatesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTaxRatesClient rawClient; + + public AsyncTaxRatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTaxRatesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTaxRatesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of TaxRate objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of TaxRate objects. + */ + public CompletableFuture list(TaxRatesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of TaxRate objects. + */ + public CompletableFuture list(TaxRatesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a TaxRate object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a TaxRate object with the given id. + */ + public CompletableFuture retrieve(String id, TaxRatesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a TaxRate object with the given id. + */ + public CompletableFuture retrieve( + String id, TaxRatesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/taxrates/RawTaxRatesClient.java b/src/main/java/com/merge/api/resources/accounting/taxrates/RawTaxRatesClient.java new file mode 100644 index 000000000..7e36c2231 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/taxrates/RawTaxRatesClient.java @@ -0,0 +1,214 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.taxrates; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.taxrates.requests.TaxRatesListRequest; +import com.merge.api.resources.accounting.taxrates.requests.TaxRatesRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedTaxRateList; +import com.merge.api.resources.accounting.types.TaxRate; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTaxRatesClient { + protected final ClientOptions clientOptions; + + public RawTaxRatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of TaxRate objects. + */ + public MergeApiHttpResponse list() { + return list(TaxRatesListRequest.builder().build()); + } + + /** + * Returns a list of TaxRate objects. + */ + public MergeApiHttpResponse list(TaxRatesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of TaxRate objects. + */ + public MergeApiHttpResponse list(TaxRatesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/tax-rates"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTaxRateList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a TaxRate object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TaxRatesRetrieveRequest.builder().build()); + } + + /** + * Returns a TaxRate object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TaxRatesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a TaxRate object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, TaxRatesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/tax-rates") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TaxRate.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/taxrates/TaxRatesClient.java b/src/main/java/com/merge/api/resources/accounting/taxrates/TaxRatesClient.java index 3b768fd30..fe3693334 100644 --- a/src/main/java/com/merge/api/resources/accounting/taxrates/TaxRatesClient.java +++ b/src/main/java/com/merge/api/resources/accounting/taxrates/TaxRatesClient.java @@ -3,173 +3,69 @@ */ package com.merge.api.resources.accounting.taxrates; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.taxrates.requests.TaxRatesListRequest; import com.merge.api.resources.accounting.taxrates.requests.TaxRatesRetrieveRequest; import com.merge.api.resources.accounting.types.PaginatedTaxRateList; import com.merge.api.resources.accounting.types.TaxRate; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TaxRatesClient { protected final ClientOptions clientOptions; + private final RawTaxRatesClient rawClient; + public TaxRatesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTaxRatesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTaxRatesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of TaxRate objects. */ public PaginatedTaxRateList list() { - return list(TaxRatesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of TaxRate objects. */ public PaginatedTaxRateList list(TaxRatesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of TaxRate objects. */ public PaginatedTaxRateList list(TaxRatesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/tax-rates"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTaxRateList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a TaxRate object with the given id. */ public TaxRate retrieve(String id) { - return retrieve(id, TaxRatesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a TaxRate object with the given id. */ public TaxRate retrieve(String id, TaxRatesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a TaxRate object with the given id. */ public TaxRate retrieve(String id, TaxRatesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/tax-rates") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TaxRate.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/taxrates/requests/TaxRatesListRequest.java b/src/main/java/com/merge/api/resources/accounting/taxrates/requests/TaxRatesListRequest.java index 4fd846e4b..b9674b4c7 100644 --- a/src/main/java/com/merge/api/resources/accounting/taxrates/requests/TaxRatesListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/taxrates/requests/TaxRatesListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TaxRatesListRequest.Builder.class) public final class TaxRatesListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -29,8 +33,6 @@ public final class TaxRatesListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -41,6 +43,8 @@ public final class TaxRatesListRequest { private final Optional modifiedBefore; + private final Optional name; + private final Optional pageSize; private final Optional remoteId; @@ -48,34 +52,44 @@ public final class TaxRatesListRequest { private final Map additionalProperties; private TaxRatesListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, Optional modifiedAfter, Optional modifiedBefore, + Optional name, Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; this.modifiedAfter = modifiedAfter; this.modifiedBefore = modifiedBefore; + this.name = name; this.pageSize = pageSize; this.remoteId = remoteId; this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return tax rates for this company. */ @@ -108,14 +122,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -156,6 +162,14 @@ public Optional getModifiedBefore() { return modifiedBefore; } + /** + * @return If provided, will only return TaxRates with this name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + /** * @return Number of results to return per page. */ @@ -184,16 +198,17 @@ public Map getAdditionalProperties() { } private boolean equalTo(TaxRatesListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) && modifiedAfter.equals(other.modifiedAfter) && modifiedBefore.equals(other.modifiedBefore) + && name.equals(other.name) && pageSize.equals(other.pageSize) && remoteId.equals(other.remoteId); } @@ -201,16 +216,17 @@ private boolean equalTo(TaxRatesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, this.modifiedAfter, this.modifiedBefore, + this.name, this.pageSize, this.remoteId); } @@ -226,6 +242,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -234,8 +252,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -246,6 +262,8 @@ public static final class Builder { private Optional modifiedBefore = Optional.empty(); + private Optional name = Optional.empty(); + private Optional pageSize = Optional.empty(); private Optional remoteId = Optional.empty(); @@ -256,21 +274,38 @@ public static final class Builder { private Builder() {} public Builder from(TaxRatesListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); modifiedAfter(other.getModifiedAfter()); modifiedBefore(other.getModifiedBefore()); + name(other.getName()); pageSize(other.getPageSize()); remoteId(other.getRemoteId()); return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -315,17 +350,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -381,6 +405,17 @@ public Builder modifiedBefore(OffsetDateTime modifiedBefore) { return this; } + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) public Builder pageSize(Optional pageSize) { this.pageSize = pageSize; @@ -405,16 +440,17 @@ public Builder remoteId(String remoteId) { public TaxRatesListRequest build() { return new TaxRatesListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, modifiedAfter, modifiedBefore, + name, pageSize, remoteId, additionalProperties); diff --git a/src/main/java/com/merge/api/resources/accounting/taxrates/requests/TaxRatesRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/taxrates/requests/TaxRatesRetrieveRequest.java index f5c825ed7..4c3f6cb92 100644 --- a/src/main/java/com/merge/api/resources/accounting/taxrates/requests/TaxRatesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/taxrates/requests/TaxRatesRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TaxRatesRetrieveRequest.Builder.class) public final class TaxRatesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private TaxRatesRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private TaxRatesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(TaxRatesRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(TaxRatesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public TaxRatesRetrieveRequest build() { - return new TaxRatesRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new TaxRatesRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/trackingcategories/AsyncRawTrackingCategoriesClient.java b/src/main/java/com/merge/api/resources/accounting/trackingcategories/AsyncRawTrackingCategoriesClient.java new file mode 100644 index 000000000..197d1c12a --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/trackingcategories/AsyncRawTrackingCategoriesClient.java @@ -0,0 +1,273 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.trackingcategories; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.trackingcategories.requests.TrackingCategoriesListRequest; +import com.merge.api.resources.accounting.trackingcategories.requests.TrackingCategoriesRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedTrackingCategoryList; +import com.merge.api.resources.accounting.types.TrackingCategory; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTrackingCategoriesClient { + protected final ClientOptions clientOptions; + + public AsyncRawTrackingCategoriesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of TrackingCategory objects. + */ + public CompletableFuture> list() { + return list(TrackingCategoriesListRequest.builder().build()); + } + + /** + * Returns a list of TrackingCategory objects. + */ + public CompletableFuture> list( + TrackingCategoriesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of TrackingCategory objects. + */ + public CompletableFuture> list( + TrackingCategoriesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/tracking-categories"); + if (request.getCategoryType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category_type", request.getCategoryType().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedTrackingCategoryList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a TrackingCategory object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TrackingCategoriesRetrieveRequest.builder().build()); + } + + /** + * Returns a TrackingCategory object with the given id. + */ + public CompletableFuture> retrieve( + String id, TrackingCategoriesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a TrackingCategory object with the given id. + */ + public CompletableFuture> retrieve( + String id, TrackingCategoriesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/tracking-categories") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TrackingCategory.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/trackingcategories/AsyncTrackingCategoriesClient.java b/src/main/java/com/merge/api/resources/accounting/trackingcategories/AsyncTrackingCategoriesClient.java new file mode 100644 index 000000000..e28e217e2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/trackingcategories/AsyncTrackingCategoriesClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.trackingcategories; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.trackingcategories.requests.TrackingCategoriesListRequest; +import com.merge.api.resources.accounting.trackingcategories.requests.TrackingCategoriesRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedTrackingCategoryList; +import com.merge.api.resources.accounting.types.TrackingCategory; +import java.util.concurrent.CompletableFuture; + +public class AsyncTrackingCategoriesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTrackingCategoriesClient rawClient; + + public AsyncTrackingCategoriesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTrackingCategoriesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTrackingCategoriesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of TrackingCategory objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of TrackingCategory objects. + */ + public CompletableFuture list(TrackingCategoriesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of TrackingCategory objects. + */ + public CompletableFuture list( + TrackingCategoriesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a TrackingCategory object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a TrackingCategory object with the given id. + */ + public CompletableFuture retrieve(String id, TrackingCategoriesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a TrackingCategory object with the given id. + */ + public CompletableFuture retrieve( + String id, TrackingCategoriesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/trackingcategories/RawTrackingCategoriesClient.java b/src/main/java/com/merge/api/resources/accounting/trackingcategories/RawTrackingCategoriesClient.java new file mode 100644 index 000000000..7f53dcb21 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/trackingcategories/RawTrackingCategoriesClient.java @@ -0,0 +1,239 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.trackingcategories; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.trackingcategories.requests.TrackingCategoriesListRequest; +import com.merge.api.resources.accounting.trackingcategories.requests.TrackingCategoriesRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedTrackingCategoryList; +import com.merge.api.resources.accounting.types.TrackingCategory; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTrackingCategoriesClient { + protected final ClientOptions clientOptions; + + public RawTrackingCategoriesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of TrackingCategory objects. + */ + public MergeApiHttpResponse list() { + return list(TrackingCategoriesListRequest.builder().build()); + } + + /** + * Returns a list of TrackingCategory objects. + */ + public MergeApiHttpResponse list(TrackingCategoriesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of TrackingCategory objects. + */ + public MergeApiHttpResponse list( + TrackingCategoriesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/tracking-categories"); + if (request.getCategoryType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category_type", request.getCategoryType().get(), false); + } + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTrackingCategoryList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a TrackingCategory object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TrackingCategoriesRetrieveRequest.builder().build()); + } + + /** + * Returns a TrackingCategory object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TrackingCategoriesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a TrackingCategory object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, TrackingCategoriesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/tracking-categories") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TrackingCategory.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/trackingcategories/TrackingCategoriesClient.java b/src/main/java/com/merge/api/resources/accounting/trackingcategories/TrackingCategoriesClient.java index eabad40e7..83e11eae4 100644 --- a/src/main/java/com/merge/api/resources/accounting/trackingcategories/TrackingCategoriesClient.java +++ b/src/main/java/com/merge/api/resources/accounting/trackingcategories/TrackingCategoriesClient.java @@ -3,140 +3,63 @@ */ package com.merge.api.resources.accounting.trackingcategories; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.trackingcategories.requests.TrackingCategoriesListRequest; import com.merge.api.resources.accounting.trackingcategories.requests.TrackingCategoriesRetrieveRequest; import com.merge.api.resources.accounting.types.PaginatedTrackingCategoryList; import com.merge.api.resources.accounting.types.TrackingCategory; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TrackingCategoriesClient { protected final ClientOptions clientOptions; + private final RawTrackingCategoriesClient rawClient; + public TrackingCategoriesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTrackingCategoriesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTrackingCategoriesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of TrackingCategory objects. */ public PaginatedTrackingCategoryList list() { - return list(TrackingCategoriesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of TrackingCategory objects. */ public PaginatedTrackingCategoryList list(TrackingCategoriesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of TrackingCategory objects. */ public PaginatedTrackingCategoryList list(TrackingCategoriesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/tracking-categories"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTrackingCategoryList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a TrackingCategory object with the given id. */ public TrackingCategory retrieve(String id) { - return retrieve(id, TrackingCategoriesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a TrackingCategory object with the given id. */ public TrackingCategory retrieve(String id, TrackingCategoriesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** @@ -144,47 +67,6 @@ public TrackingCategory retrieve(String id, TrackingCategoriesRetrieveRequest re */ public TrackingCategory retrieve( String id, TrackingCategoriesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/tracking-categories") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TrackingCategory.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/trackingcategories/requests/TrackingCategoriesListRequest.java b/src/main/java/com/merge/api/resources/accounting/trackingcategories/requests/TrackingCategoriesListRequest.java index 310b4dd81..e2e4f9c85 100644 --- a/src/main/java/com/merge/api/resources/accounting/trackingcategories/requests/TrackingCategoriesListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/trackingcategories/requests/TrackingCategoriesListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,6 +23,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TrackingCategoriesListRequest.Builder.class) public final class TrackingCategoriesListRequest { + private final Optional> expand; + + private final Optional categoryType; + private final Optional companyId; private final Optional createdAfter; @@ -29,8 +35,6 @@ public final class TrackingCategoriesListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -41,6 +45,8 @@ public final class TrackingCategoriesListRequest { private final Optional modifiedBefore; + private final Optional name; + private final Optional pageSize; private final Optional remoteFields; @@ -49,41 +55,65 @@ public final class TrackingCategoriesListRequest { private final Optional showEnumOrigins; + private final Optional status; + private final Map additionalProperties; private TrackingCategoriesListRequest( + Optional> expand, + Optional categoryType, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, Optional modifiedAfter, Optional modifiedBefore, + Optional name, Optional pageSize, Optional remoteFields, Optional remoteId, Optional showEnumOrigins, + Optional status, Map additionalProperties) { + this.expand = expand; + this.categoryType = categoryType; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; this.modifiedAfter = modifiedAfter; this.modifiedBefore = modifiedBefore; + this.name = name; this.pageSize = pageSize; this.remoteFields = remoteFields; this.remoteId = remoteId; this.showEnumOrigins = showEnumOrigins; + this.status = status; this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + + /** + * @return If provided, will only return tracking categories with this type. + */ + @JsonProperty("category_type") + public Optional getCategoryType() { + return categoryType; + } + /** * @return If provided, will only return tracking categories for this company. */ @@ -116,14 +146,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -164,6 +186,14 @@ public Optional getModifiedBefore() { return modifiedBefore; } + /** + * @return If provided, will only return TrackingCategories with this name. + */ + @JsonProperty("name") + public Optional getName() { + return name; + } + /** * @return Number of results to return per page. */ @@ -196,6 +226,14 @@ public Optional getShowEnumOrigins() { return showEnumOrigins; } + /** + * @return If provided, will only return tracking categories with this status. + */ + @JsonProperty("status") + public Optional getStatus() { + return status; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -208,39 +246,45 @@ public Map getAdditionalProperties() { } private boolean equalTo(TrackingCategoriesListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && categoryType.equals(other.categoryType) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) && modifiedAfter.equals(other.modifiedAfter) && modifiedBefore.equals(other.modifiedBefore) + && name.equals(other.name) && pageSize.equals(other.pageSize) && remoteFields.equals(other.remoteFields) && remoteId.equals(other.remoteId) - && showEnumOrigins.equals(other.showEnumOrigins); + && showEnumOrigins.equals(other.showEnumOrigins) + && status.equals(other.status); } @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, + this.categoryType, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, this.modifiedAfter, this.modifiedBefore, + this.name, this.pageSize, this.remoteFields, this.remoteId, - this.showEnumOrigins); + this.showEnumOrigins, + this.status); } @java.lang.Override @@ -254,6 +298,10 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + + private Optional categoryType = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -262,8 +310,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -274,6 +320,8 @@ public static final class Builder { private Optional modifiedBefore = Optional.empty(); + private Optional name = Optional.empty(); + private Optional pageSize = Optional.empty(); private Optional remoteFields = Optional.empty(); @@ -282,26 +330,58 @@ public static final class Builder { private Optional showEnumOrigins = Optional.empty(); + private Optional status = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} public Builder from(TrackingCategoriesListRequest other) { + expand(other.getExpand()); + categoryType(other.getCategoryType()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); modifiedAfter(other.getModifiedAfter()); modifiedBefore(other.getModifiedBefore()); + name(other.getName()); pageSize(other.getPageSize()); remoteFields(other.getRemoteFields()); remoteId(other.getRemoteId()); showEnumOrigins(other.getShowEnumOrigins()); + status(other.getStatus()); + return this; + } + + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + + @JsonSetter(value = "category_type", nulls = Nulls.SKIP) + public Builder categoryType(Optional categoryType) { + this.categoryType = categoryType; + return this; + } + + public Builder categoryType(String categoryType) { + this.categoryType = Optional.ofNullable(categoryType); return this; } @@ -349,17 +429,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -415,6 +484,17 @@ public Builder modifiedBefore(OffsetDateTime modifiedBefore) { return this; } + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) public Builder pageSize(Optional pageSize) { this.pageSize = pageSize; @@ -459,22 +539,36 @@ public Builder showEnumOrigins(String showEnumOrigins) { return this; } + @JsonSetter(value = "status", nulls = Nulls.SKIP) + public Builder status(Optional status) { + this.status = status; + return this; + } + + public Builder status(String status) { + this.status = Optional.ofNullable(status); + return this; + } + public TrackingCategoriesListRequest build() { return new TrackingCategoriesListRequest( + expand, + categoryType, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, modifiedAfter, modifiedBefore, + name, pageSize, remoteFields, remoteId, showEnumOrigins, + status, additionalProperties); } } diff --git a/src/main/java/com/merge/api/resources/accounting/trackingcategories/requests/TrackingCategoriesRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/trackingcategories/requests/TrackingCategoriesRetrieveRequest.java index 6f6f9a372..01acba740 100644 --- a/src/main/java/com/merge/api/resources/accounting/trackingcategories/requests/TrackingCategoriesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/trackingcategories/requests/TrackingCategoriesRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,10 +22,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TrackingCategoriesRetrieveRequest.Builder.class) public final class TrackingCategoriesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -31,13 +35,15 @@ public final class TrackingCategoriesRetrieveRequest { private final Map additionalProperties; private TrackingCategoriesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -47,7 +53,7 @@ private TrackingCategoriesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -59,6 +65,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -89,13 +103,15 @@ public Map getAdditionalProperties() { private boolean equalTo(TrackingCategoriesRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -109,10 +125,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -125,22 +143,28 @@ private Builder() {} public Builder from(TrackingCategoriesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -152,6 +176,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -176,7 +211,7 @@ public Builder showEnumOrigins(String showEnumOrigins) { public TrackingCategoriesRetrieveRequest build() { return new TrackingCategoriesRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/transactions/AsyncRawTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/transactions/AsyncRawTransactionsClient.java new file mode 100644 index 000000000..24c7f66ba --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/transactions/AsyncRawTransactionsClient.java @@ -0,0 +1,258 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.transactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.transactions.requests.TransactionsListRequest; +import com.merge.api.resources.accounting.transactions.requests.TransactionsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedTransactionList; +import com.merge.api.resources.accounting.types.Transaction; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTransactionsClient { + protected final ClientOptions clientOptions; + + public AsyncRawTransactionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Transaction objects. + */ + public CompletableFuture> list() { + return list(TransactionsListRequest.builder().build()); + } + + /** + * Returns a list of Transaction objects. + */ + public CompletableFuture> list(TransactionsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Transaction objects. + */ + public CompletableFuture> list( + TransactionsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/transactions"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedTransactionList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Transaction object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TransactionsRetrieveRequest.builder().build()); + } + + /** + * Returns a Transaction object with the given id. + */ + public CompletableFuture> retrieve( + String id, TransactionsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Transaction object with the given id. + */ + public CompletableFuture> retrieve( + String id, TransactionsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/transactions") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Transaction.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/transactions/AsyncTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/transactions/AsyncTransactionsClient.java new file mode 100644 index 000000000..329cd301f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/transactions/AsyncTransactionsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.transactions; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.transactions.requests.TransactionsListRequest; +import com.merge.api.resources.accounting.transactions.requests.TransactionsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedTransactionList; +import com.merge.api.resources.accounting.types.Transaction; +import java.util.concurrent.CompletableFuture; + +public class AsyncTransactionsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTransactionsClient rawClient; + + public AsyncTransactionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTransactionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTransactionsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Transaction objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Transaction objects. + */ + public CompletableFuture list(TransactionsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Transaction objects. + */ + public CompletableFuture list( + TransactionsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Transaction object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Transaction object with the given id. + */ + public CompletableFuture retrieve(String id, TransactionsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Transaction object with the given id. + */ + public CompletableFuture retrieve( + String id, TransactionsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/transactions/RawTransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/transactions/RawTransactionsClient.java new file mode 100644 index 000000000..52fa20bd3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/transactions/RawTransactionsClient.java @@ -0,0 +1,225 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.transactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.transactions.requests.TransactionsListRequest; +import com.merge.api.resources.accounting.transactions.requests.TransactionsRetrieveRequest; +import com.merge.api.resources.accounting.types.PaginatedTransactionList; +import com.merge.api.resources.accounting.types.Transaction; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTransactionsClient { + protected final ClientOptions clientOptions; + + public RawTransactionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Transaction objects. + */ + public MergeApiHttpResponse list() { + return list(TransactionsListRequest.builder().build()); + } + + /** + * Returns a list of Transaction objects. + */ + public MergeApiHttpResponse list(TransactionsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Transaction objects. + */ + public MergeApiHttpResponse list( + TransactionsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/transactions"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTransactionList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Transaction object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TransactionsRetrieveRequest.builder().build()); + } + + /** + * Returns a Transaction object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TransactionsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Transaction object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, TransactionsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/transactions") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Transaction.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/transactions/TransactionsClient.java b/src/main/java/com/merge/api/resources/accounting/transactions/TransactionsClient.java index b7727fa63..75860a560 100644 --- a/src/main/java/com/merge/api/resources/accounting/transactions/TransactionsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/transactions/TransactionsClient.java @@ -3,183 +3,69 @@ */ package com.merge.api.resources.accounting.transactions; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.transactions.requests.TransactionsListRequest; import com.merge.api.resources.accounting.transactions.requests.TransactionsRetrieveRequest; import com.merge.api.resources.accounting.types.PaginatedTransactionList; import com.merge.api.resources.accounting.types.Transaction; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TransactionsClient { protected final ClientOptions clientOptions; + private final RawTransactionsClient rawClient; + public TransactionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTransactionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTransactionsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Transaction objects. */ public PaginatedTransactionList list() { - return list(TransactionsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Transaction objects. */ public PaginatedTransactionList list(TransactionsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Transaction objects. */ public PaginatedTransactionList list(TransactionsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/transactions"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getTransactionDateAfter().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_after", - request.getTransactionDateAfter().get().toString()); - } - if (request.getTransactionDateBefore().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_before", - request.getTransactionDateBefore().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTransactionList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Transaction object with the given id. */ public Transaction retrieve(String id) { - return retrieve(id, TransactionsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Transaction object with the given id. */ public Transaction retrieve(String id, TransactionsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Transaction object with the given id. */ public Transaction retrieve(String id, TransactionsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/transactions") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Transaction.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/transactions/requests/TransactionsListRequest.java b/src/main/java/com/merge/api/resources/accounting/transactions/requests/TransactionsListRequest.java index a831163d3..c1abd9e8d 100644 --- a/src/main/java/com/merge/api/resources/accounting/transactions/requests/TransactionsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/transactions/requests/TransactionsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.transactions.types.TransactionsListRequestExpand; +import com.merge.api.resources.accounting.transactions.types.TransactionsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TransactionsListRequest.Builder.class) public final class TransactionsListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -30,8 +34,6 @@ public final class TransactionsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -53,11 +55,11 @@ public final class TransactionsListRequest { private final Map additionalProperties; private TransactionsListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -68,11 +70,11 @@ private TransactionsListRequest( Optional transactionDateAfter, Optional transactionDateBefore, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -85,6 +87,14 @@ private TransactionsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return accounting transactions for this company. */ @@ -117,14 +127,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -209,11 +211,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(TransactionsListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -228,11 +230,11 @@ private boolean equalTo(TransactionsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -255,6 +257,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -263,8 +267,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -289,11 +291,11 @@ public static final class Builder { private Builder() {} public Builder from(TransactionsListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -306,6 +308,22 @@ public Builder from(TransactionsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(TransactionsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -350,17 +368,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(TransactionsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -462,11 +469,11 @@ public Builder transactionDateBefore(OffsetDateTime transactionDateBefore) { public TransactionsListRequest build() { return new TransactionsListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/transactions/requests/TransactionsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/transactions/requests/TransactionsRetrieveRequest.java index 6d14b2dc4..86a300c84 100644 --- a/src/main/java/com/merge/api/resources/accounting/transactions/requests/TransactionsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/transactions/requests/TransactionsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.transactions.types.TransactionsRetrieveRequestExpand; +import com.merge.api.resources.accounting.transactions.types.TransactionsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TransactionsRetrieveRequest.Builder.class) public final class TransactionsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private TransactionsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private TransactionsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(TransactionsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -83,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,20 +113,26 @@ private Builder() {} public Builder from(TransactionsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(TransactionsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(TransactionsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -120,8 +144,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public TransactionsRetrieveRequest build() { - return new TransactionsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new TransactionsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsListRequestExpand.java deleted file mode 100644 index bf80268d0..000000000 --- a/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsListRequestExpand.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.transactions.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TransactionsListRequestExpand { - ACCOUNT("account"), - - ACCOUNT_ACCOUNTING_PERIOD("account,accounting_period"), - - ACCOUNTING_PERIOD("accounting_period"), - - CONTACT("contact"), - - CONTACT_ACCOUNT("contact,account"), - - CONTACT_ACCOUNT_ACCOUNTING_PERIOD("contact,account,accounting_period"), - - CONTACT_ACCOUNTING_PERIOD("contact,accounting_period"), - - LINE_ITEMS("line_items"), - - LINE_ITEMS_ACCOUNT("line_items,account"), - - LINE_ITEMS_ACCOUNT_ACCOUNTING_PERIOD("line_items,account,accounting_period"), - - LINE_ITEMS_ACCOUNTING_PERIOD("line_items,accounting_period"), - - LINE_ITEMS_CONTACT("line_items,contact"), - - LINE_ITEMS_CONTACT_ACCOUNT("line_items,contact,account"), - - LINE_ITEMS_CONTACT_ACCOUNT_ACCOUNTING_PERIOD("line_items,contact,account,accounting_period"), - - LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("line_items,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES("line_items,tracking_categories"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNT("line_items,tracking_categories,account"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,account,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("line_items,tracking_categories,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("line_items,tracking_categories,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNT("line_items,tracking_categories,contact,account"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,account,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNT("tracking_categories,account"), - - TRACKING_CATEGORIES_ACCOUNT_ACCOUNTING_PERIOD("tracking_categories,account,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_CONTACT("tracking_categories,contact"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT("tracking_categories,contact,account"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT_ACCOUNTING_PERIOD("tracking_categories,contact,account,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("tracking_categories,contact,accounting_period"); - - private final String value; - - TransactionsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsListRequestExpandItem.java new file mode 100644 index 000000000..021b6a4c5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsListRequestExpandItem.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.transactions.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TransactionsListRequestExpandItem { + ACCOUNT("account"), + + ACCOUNTING_PERIOD("accounting_period"), + + CONTACT("contact"), + + LINE_ITEMS("line_items"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + TransactionsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsRetrieveRequestExpand.java deleted file mode 100644 index 8c816c1fc..000000000 --- a/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsRetrieveRequestExpand.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.transactions.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TransactionsRetrieveRequestExpand { - ACCOUNT("account"), - - ACCOUNT_ACCOUNTING_PERIOD("account,accounting_period"), - - ACCOUNTING_PERIOD("accounting_period"), - - CONTACT("contact"), - - CONTACT_ACCOUNT("contact,account"), - - CONTACT_ACCOUNT_ACCOUNTING_PERIOD("contact,account,accounting_period"), - - CONTACT_ACCOUNTING_PERIOD("contact,accounting_period"), - - LINE_ITEMS("line_items"), - - LINE_ITEMS_ACCOUNT("line_items,account"), - - LINE_ITEMS_ACCOUNT_ACCOUNTING_PERIOD("line_items,account,accounting_period"), - - LINE_ITEMS_ACCOUNTING_PERIOD("line_items,accounting_period"), - - LINE_ITEMS_CONTACT("line_items,contact"), - - LINE_ITEMS_CONTACT_ACCOUNT("line_items,contact,account"), - - LINE_ITEMS_CONTACT_ACCOUNT_ACCOUNTING_PERIOD("line_items,contact,account,accounting_period"), - - LINE_ITEMS_CONTACT_ACCOUNTING_PERIOD("line_items,contact,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES("line_items,tracking_categories"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNT("line_items,tracking_categories,account"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,account,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("line_items,tracking_categories,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT("line_items,tracking_categories,contact"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNT("line_items,tracking_categories,contact,account"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,account,accounting_period"), - - LINE_ITEMS_TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD( - "line_items,tracking_categories,contact,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNT("tracking_categories,account"), - - TRACKING_CATEGORIES_ACCOUNT_ACCOUNTING_PERIOD("tracking_categories,account,accounting_period"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_CONTACT("tracking_categories,contact"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT("tracking_categories,contact,account"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNT_ACCOUNTING_PERIOD("tracking_categories,contact,account,accounting_period"), - - TRACKING_CATEGORIES_CONTACT_ACCOUNTING_PERIOD("tracking_categories,contact,accounting_period"); - - private final String value; - - TransactionsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..cba8fe0a8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/transactions/types/TransactionsRetrieveRequestExpandItem.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.transactions.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TransactionsRetrieveRequestExpandItem { + ACCOUNT("account"), + + ACCOUNTING_PERIOD("accounting_period"), + + CONTACT("contact"), + + LINE_ITEMS("line_items"), + + TRACKING_CATEGORIES("tracking_categories"); + + private final String value; + + TransactionsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/Account.java b/src/main/java/com/merge/api/resources/accounting/types/Account.java index cdf071ea9..e99ab42b4 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/Account.java +++ b/src/main/java/com/merge/api/resources/accounting/types/Account.java @@ -35,17 +35,17 @@ public final class Account { private final Optional description; - private final Optional classification; + private final Optional classification; private final Optional type; - private final Optional accountType; + private final Optional accountType; - private final Optional status; + private final Optional status; private final Optional currentBalance; - private final Optional currency; + private final Optional currency; private final Optional accountNumber; @@ -68,12 +68,12 @@ private Account( Optional modifiedAt, Optional name, Optional description, - Optional classification, + Optional classification, Optional type, - Optional accountType, - Optional status, + Optional accountType, + Optional status, Optional currentBalance, - Optional currency, + Optional currency, Optional accountNumber, Optional parentAccount, Optional company, @@ -158,7 +158,7 @@ public Optional getDescription() { * */ @JsonProperty("classification") - public Optional getClassification() { + public Optional getClassification() { return classification; } @@ -189,7 +189,7 @@ public Optional getType() { * */ @JsonProperty("account_type") - public Optional getAccountType() { + public Optional getAccountType() { return accountType; } @@ -202,7 +202,7 @@ public Optional getAccountType() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -526,7 +526,7 @@ public Optional getCurrentBalance() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -650,17 +650,17 @@ public static final class Builder { private Optional description = Optional.empty(); - private Optional classification = Optional.empty(); + private Optional classification = Optional.empty(); private Optional type = Optional.empty(); - private Optional accountType = Optional.empty(); + private Optional accountType = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional currentBalance = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional accountNumber = Optional.empty(); @@ -768,12 +768,12 @@ public Builder description(String description) { } @JsonSetter(value = "classification", nulls = Nulls.SKIP) - public Builder classification(Optional classification) { + public Builder classification(Optional classification) { this.classification = classification; return this; } - public Builder classification(AccountClassification classification) { + public Builder classification(ClassificationEnum classification) { this.classification = Optional.ofNullable(classification); return this; } @@ -790,23 +790,23 @@ public Builder type(String type) { } @JsonSetter(value = "account_type", nulls = Nulls.SKIP) - public Builder accountType(Optional accountType) { + public Builder accountType(Optional accountType) { this.accountType = accountType; return this; } - public Builder accountType(AccountAccountType accountType) { + public Builder accountType(AccountAccountTypeEnum accountType) { this.accountType = Optional.ofNullable(accountType); return this; } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(AccountStatus status) { + public Builder status(AccountStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -823,12 +823,12 @@ public Builder currentBalance(Double currentBalance) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(AccountCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountAccountType.java b/src/main/java/com/merge/api/resources/accounting/types/AccountAccountType.java deleted file mode 100644 index fbd63a7e8..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountAccountType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AccountAccountType.Deserializer.class) -public final class AccountAccountType { - private final Object value; - - private final int type; - - private AccountAccountType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AccountAccountTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AccountAccountType && equalTo((AccountAccountType) other); - } - - private boolean equalTo(AccountAccountType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AccountAccountType of(AccountAccountTypeEnum value) { - return new AccountAccountType(value, 0); - } - - public static AccountAccountType of(String value) { - return new AccountAccountType(value, 1); - } - - public interface Visitor { - T visit(AccountAccountTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AccountAccountType.class); - } - - @java.lang.Override - public AccountAccountType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AccountAccountTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountClassification.java b/src/main/java/com/merge/api/resources/accounting/types/AccountClassification.java deleted file mode 100644 index 2c96d0441..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountClassification.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AccountClassification.Deserializer.class) -public final class AccountClassification { - private final Object value; - - private final int type; - - private AccountClassification(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ClassificationEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AccountClassification && equalTo((AccountClassification) other); - } - - private boolean equalTo(AccountClassification other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AccountClassification of(ClassificationEnum value) { - return new AccountClassification(value, 0); - } - - public static AccountClassification of(String value) { - return new AccountClassification(value, 1); - } - - public interface Visitor { - T visit(ClassificationEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AccountClassification.class); - } - - @java.lang.Override - public AccountClassification deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ClassificationEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/AccountCurrency.java deleted file mode 100644 index 96ffdddd0..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AccountCurrency.Deserializer.class) -public final class AccountCurrency { - private final Object value; - - private final int type; - - private AccountCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AccountCurrency && equalTo((AccountCurrency) other); - } - - private boolean equalTo(AccountCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AccountCurrency of(TransactionCurrencyEnum value) { - return new AccountCurrency(value, 0); - } - - public static AccountCurrency of(String value) { - return new AccountCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AccountCurrency.class); - } - - @java.lang.Override - public AccountCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountRequest.java b/src/main/java/com/merge/api/resources/accounting/types/AccountRequest.java index bc6dacbad..525a769b1 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/AccountRequest.java @@ -25,17 +25,17 @@ public final class AccountRequest { private final Optional description; - private final Optional classification; + private final Optional classification; private final Optional type; - private final Optional accountType; + private final Optional accountType; - private final Optional status; + private final Optional status; private final Optional currentBalance; - private final Optional currency; + private final Optional currency; private final Optional accountNumber; @@ -52,12 +52,12 @@ public final class AccountRequest { private AccountRequest( Optional name, Optional description, - Optional classification, + Optional classification, Optional type, - Optional accountType, - Optional status, + Optional accountType, + Optional status, Optional currentBalance, - Optional currency, + Optional currency, Optional accountNumber, Optional parentAccount, Optional company, @@ -107,7 +107,7 @@ public Optional getDescription() { * */ @JsonProperty("classification") - public Optional getClassification() { + public Optional getClassification() { return classification; } @@ -138,7 +138,7 @@ public Optional getType() { * */ @JsonProperty("account_type") - public Optional getAccountType() { + public Optional getAccountType() { return accountType; } @@ -151,7 +151,7 @@ public Optional getAccountType() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -475,7 +475,7 @@ public Optional getCurrentBalance() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -573,17 +573,17 @@ public static final class Builder { private Optional description = Optional.empty(); - private Optional classification = Optional.empty(); + private Optional classification = Optional.empty(); private Optional type = Optional.empty(); - private Optional accountType = Optional.empty(); + private Optional accountType = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional currentBalance = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional accountNumber = Optional.empty(); @@ -640,12 +640,12 @@ public Builder description(String description) { } @JsonSetter(value = "classification", nulls = Nulls.SKIP) - public Builder classification(Optional classification) { + public Builder classification(Optional classification) { this.classification = classification; return this; } - public Builder classification(AccountRequestClassification classification) { + public Builder classification(ClassificationEnum classification) { this.classification = Optional.ofNullable(classification); return this; } @@ -662,23 +662,23 @@ public Builder type(String type) { } @JsonSetter(value = "account_type", nulls = Nulls.SKIP) - public Builder accountType(Optional accountType) { + public Builder accountType(Optional accountType) { this.accountType = accountType; return this; } - public Builder accountType(AccountRequestAccountType accountType) { + public Builder accountType(AccountAccountTypeEnum accountType) { this.accountType = Optional.ofNullable(accountType); return this; } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(AccountRequestStatus status) { + public Builder status(AccountStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -695,12 +695,12 @@ public Builder currentBalance(Double currentBalance) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(AccountRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountRequestAccountType.java b/src/main/java/com/merge/api/resources/accounting/types/AccountRequestAccountType.java deleted file mode 100644 index db7767408..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountRequestAccountType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AccountRequestAccountType.Deserializer.class) -public final class AccountRequestAccountType { - private final Object value; - - private final int type; - - private AccountRequestAccountType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AccountAccountTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AccountRequestAccountType && equalTo((AccountRequestAccountType) other); - } - - private boolean equalTo(AccountRequestAccountType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AccountRequestAccountType of(AccountAccountTypeEnum value) { - return new AccountRequestAccountType(value, 0); - } - - public static AccountRequestAccountType of(String value) { - return new AccountRequestAccountType(value, 1); - } - - public interface Visitor { - T visit(AccountAccountTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AccountRequestAccountType.class); - } - - @java.lang.Override - public AccountRequestAccountType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AccountAccountTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountRequestClassification.java b/src/main/java/com/merge/api/resources/accounting/types/AccountRequestClassification.java deleted file mode 100644 index cd0b768cb..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountRequestClassification.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AccountRequestClassification.Deserializer.class) -public final class AccountRequestClassification { - private final Object value; - - private final int type; - - private AccountRequestClassification(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ClassificationEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AccountRequestClassification && equalTo((AccountRequestClassification) other); - } - - private boolean equalTo(AccountRequestClassification other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AccountRequestClassification of(ClassificationEnum value) { - return new AccountRequestClassification(value, 0); - } - - public static AccountRequestClassification of(String value) { - return new AccountRequestClassification(value, 1); - } - - public interface Visitor { - T visit(ClassificationEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AccountRequestClassification.class); - } - - @java.lang.Override - public AccountRequestClassification deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ClassificationEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountRequestCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/AccountRequestCurrency.java deleted file mode 100644 index f5675288f..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountRequestCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AccountRequestCurrency.Deserializer.class) -public final class AccountRequestCurrency { - private final Object value; - - private final int type; - - private AccountRequestCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AccountRequestCurrency && equalTo((AccountRequestCurrency) other); - } - - private boolean equalTo(AccountRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AccountRequestCurrency of(TransactionCurrencyEnum value) { - return new AccountRequestCurrency(value, 0); - } - - public static AccountRequestCurrency of(String value) { - return new AccountRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AccountRequestCurrency.class); - } - - @java.lang.Override - public AccountRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountRequestStatus.java b/src/main/java/com/merge/api/resources/accounting/types/AccountRequestStatus.java deleted file mode 100644 index 282f3aa4f..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountRequestStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AccountRequestStatus.Deserializer.class) -public final class AccountRequestStatus { - private final Object value; - - private final int type; - - private AccountRequestStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AccountStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AccountRequestStatus && equalTo((AccountRequestStatus) other); - } - - private boolean equalTo(AccountRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AccountRequestStatus of(AccountStatusEnum value) { - return new AccountRequestStatus(value, 0); - } - - public static AccountRequestStatus of(String value) { - return new AccountRequestStatus(value, 1); - } - - public interface Visitor { - T visit(AccountStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AccountRequestStatus.class); - } - - @java.lang.Override - public AccountRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AccountStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountStatus.java b/src/main/java/com/merge/api/resources/accounting/types/AccountStatus.java deleted file mode 100644 index bfc8eecd6..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AccountStatus.Deserializer.class) -public final class AccountStatus { - private final Object value; - - private final int type; - - private AccountStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AccountStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AccountStatus && equalTo((AccountStatus) other); - } - - private boolean equalTo(AccountStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AccountStatus of(AccountStatusEnum value) { - return new AccountStatus(value, 0); - } - - public static AccountStatus of(String value) { - return new AccountStatus(value, 1); - } - - public interface Visitor { - T visit(AccountStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AccountStatus.class); - } - - @java.lang.Override - public AccountStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AccountStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountToken.java b/src/main/java/com/merge/api/resources/accounting/types/AccountToken.java index 08643227f..bd0247baa 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountToken.java +++ b/src/main/java/com/merge/api/resources/accounting/types/AccountToken.java @@ -23,12 +23,15 @@ public final class AccountToken { private final AccountIntegration integration; + private final String id; + private final Map additionalProperties; private AccountToken( - String accountToken, AccountIntegration integration, Map additionalProperties) { + String accountToken, AccountIntegration integration, String id, Map additionalProperties) { this.accountToken = accountToken; this.integration = integration; + this.id = id; this.additionalProperties = additionalProperties; } @@ -42,6 +45,11 @@ public AccountIntegration getIntegration() { return integration; } + @JsonProperty("id") + public String getId() { + return id; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -54,12 +62,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(AccountToken other) { - return accountToken.equals(other.accountToken) && integration.equals(other.integration); + return accountToken.equals(other.accountToken) && integration.equals(other.integration) && id.equals(other.id); } @java.lang.Override public int hashCode() { - return Objects.hash(this.accountToken, this.integration); + return Objects.hash(this.accountToken, this.integration, this.id); } @java.lang.Override @@ -78,7 +86,11 @@ public interface AccountTokenStage { } public interface IntegrationStage { - _FinalStage integration(@NotNull AccountIntegration integration); + IdStage integration(@NotNull AccountIntegration integration); + } + + public interface IdStage { + _FinalStage id(@NotNull String id); } public interface _FinalStage { @@ -86,11 +98,13 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AccountTokenStage, IntegrationStage, _FinalStage { + public static final class Builder implements AccountTokenStage, IntegrationStage, IdStage, _FinalStage { private String accountToken; private AccountIntegration integration; + private String id; + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -100,6 +114,7 @@ private Builder() {} public Builder from(AccountToken other) { accountToken(other.getAccountToken()); integration(other.getIntegration()); + id(other.getId()); return this; } @@ -112,14 +127,21 @@ public IntegrationStage accountToken(@NotNull String accountToken) { @java.lang.Override @JsonSetter("integration") - public _FinalStage integration(@NotNull AccountIntegration integration) { + public IdStage integration(@NotNull AccountIntegration integration) { this.integration = integration; return this; } + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = id; + return this; + } + @java.lang.Override public AccountToken build() { - return new AccountToken(accountToken, integration, additionalProperties); + return new AccountToken(accountToken, integration, id, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/AccountingPeriod.java index 238313681..cce3c1f06 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/AccountingPeriod.java @@ -33,7 +33,7 @@ public final class AccountingPeriod { private final Optional name; - private final Optional status; + private final Optional status; private final Optional startDate; @@ -51,7 +51,7 @@ private AccountingPeriod( Optional createdAt, Optional modifiedAt, Optional name, - Optional status, + Optional status, Optional startDate, Optional endDate, Optional> fieldMappings, @@ -108,7 +108,7 @@ public Optional getName() { } @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -198,7 +198,7 @@ public static final class Builder { private Optional name = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional startDate = Optional.empty(); @@ -283,12 +283,12 @@ public Builder name(String name) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(AccountingPeriodStatus status) { + public Builder status(Status895Enum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/AccountingPeriodStatus.java b/src/main/java/com/merge/api/resources/accounting/types/AccountingPeriodStatus.java deleted file mode 100644 index fcc6cab69..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AccountingPeriodStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AccountingPeriodStatus.Deserializer.class) -public final class AccountingPeriodStatus { - private final Object value; - - private final int type; - - private AccountingPeriodStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Status895Enum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AccountingPeriodStatus && equalTo((AccountingPeriodStatus) other); - } - - private boolean equalTo(AccountingPeriodStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AccountingPeriodStatus of(Status895Enum value) { - return new AccountingPeriodStatus(value, 0); - } - - public static AccountingPeriodStatus of(String value) { - return new AccountingPeriodStatus(value, 1); - } - - public interface Visitor { - T visit(Status895Enum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AccountingPeriodStatus.class); - } - - @java.lang.Override - public AccountingPeriodStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, Status895Enum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/Address.java b/src/main/java/com/merge/api/resources/accounting/types/Address.java index f13b182ae..da71ecae5 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/Address.java +++ b/src/main/java/com/merge/api/resources/accounting/types/Address.java @@ -26,7 +26,7 @@ public final class Address { private final Optional modifiedAt; - private final Optional type; + private final Optional type; private final Optional street1; @@ -38,7 +38,7 @@ public final class Address { private final Optional countrySubdivision; - private final Optional country; + private final Optional country; private final Optional zipCode; @@ -47,13 +47,13 @@ public final class Address { private Address( Optional createdAt, Optional modifiedAt, - Optional type, + Optional type, Optional street1, Optional street2, Optional city, Optional state, Optional countrySubdivision, - Optional country, + Optional country, Optional zipCode, Map additionalProperties) { this.createdAt = createdAt; @@ -93,7 +93,7 @@ public Optional getModifiedAt() { * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -389,7 +389,7 @@ public Optional getCountrySubdivision() { * */ @JsonProperty("country") - public Optional getCountry() { + public Optional getCountry() { return country; } @@ -455,7 +455,7 @@ public static final class Builder { private Optional modifiedAt = Optional.empty(); - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); private Optional street1 = Optional.empty(); @@ -467,7 +467,7 @@ public static final class Builder { private Optional countrySubdivision = Optional.empty(); - private Optional country = Optional.empty(); + private Optional country = Optional.empty(); private Optional zipCode = Optional.empty(); @@ -513,12 +513,12 @@ public Builder modifiedAt(OffsetDateTime modifiedAt) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(AddressType type) { + public Builder type(AddressTypeEnum type) { this.type = Optional.ofNullable(type); return this; } @@ -579,12 +579,12 @@ public Builder countrySubdivision(String countrySubdivision) { } @JsonSetter(value = "country", nulls = Nulls.SKIP) - public Builder country(Optional country) { + public Builder country(Optional country) { this.country = country; return this; } - public Builder country(AddressCountry country) { + public Builder country(CountryEnum country) { this.country = Optional.ofNullable(country); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/AddressCountry.java b/src/main/java/com/merge/api/resources/accounting/types/AddressCountry.java deleted file mode 100644 index 563063501..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AddressCountry.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AddressCountry.Deserializer.class) -public final class AddressCountry { - private final Object value; - - private final int type; - - private AddressCountry(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CountryEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddressCountry && equalTo((AddressCountry) other); - } - - private boolean equalTo(AddressCountry other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AddressCountry of(CountryEnum value) { - return new AddressCountry(value, 0); - } - - public static AddressCountry of(String value) { - return new AddressCountry(value, 1); - } - - public interface Visitor { - T visit(CountryEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AddressCountry.class); - } - - @java.lang.Override - public AddressCountry deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CountryEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AddressRequest.java b/src/main/java/com/merge/api/resources/accounting/types/AddressRequest.java index 66dbb21f1..68c7411a8 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/AddressRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/AddressRequest.java @@ -21,7 +21,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AddressRequest.Builder.class) public final class AddressRequest { - private final Optional type; + private final Optional type; private final Optional street1; @@ -31,7 +31,7 @@ public final class AddressRequest { private final Optional countrySubdivision; - private final Optional country; + private final Optional country; private final Optional zipCode; @@ -42,12 +42,12 @@ public final class AddressRequest { private final Map additionalProperties; private AddressRequest( - Optional type, + Optional type, Optional street1, Optional street2, Optional city, Optional countrySubdivision, - Optional country, + Optional country, Optional zipCode, Optional> integrationParams, Optional> linkedAccountParams, @@ -72,7 +72,7 @@ private AddressRequest( * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -363,7 +363,7 @@ public Optional getCountrySubdivision() { * */ @JsonProperty("country") - public Optional getCountry() { + public Optional getCountry() { return country; } @@ -433,7 +433,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); private Optional street1 = Optional.empty(); @@ -443,7 +443,7 @@ public static final class Builder { private Optional countrySubdivision = Optional.empty(); - private Optional country = Optional.empty(); + private Optional country = Optional.empty(); private Optional zipCode = Optional.empty(); @@ -470,12 +470,12 @@ public Builder from(AddressRequest other) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(AddressRequestType type) { + public Builder type(AddressTypeEnum type) { this.type = Optional.ofNullable(type); return this; } @@ -525,12 +525,12 @@ public Builder countrySubdivision(String countrySubdivision) { } @JsonSetter(value = "country", nulls = Nulls.SKIP) - public Builder country(Optional country) { + public Builder country(Optional country) { this.country = country; return this; } - public Builder country(AddressRequestCountry country) { + public Builder country(CountryEnum country) { this.country = Optional.ofNullable(country); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/AddressRequestCountry.java b/src/main/java/com/merge/api/resources/accounting/types/AddressRequestCountry.java deleted file mode 100644 index 2447656bf..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AddressRequestCountry.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AddressRequestCountry.Deserializer.class) -public final class AddressRequestCountry { - private final Object value; - - private final int type; - - private AddressRequestCountry(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CountryEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddressRequestCountry && equalTo((AddressRequestCountry) other); - } - - private boolean equalTo(AddressRequestCountry other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AddressRequestCountry of(CountryEnum value) { - return new AddressRequestCountry(value, 0); - } - - public static AddressRequestCountry of(String value) { - return new AddressRequestCountry(value, 1); - } - - public interface Visitor { - T visit(CountryEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AddressRequestCountry.class); - } - - @java.lang.Override - public AddressRequestCountry deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CountryEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AddressRequestType.java b/src/main/java/com/merge/api/resources/accounting/types/AddressRequestType.java deleted file mode 100644 index 1fe829512..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AddressRequestType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AddressRequestType.Deserializer.class) -public final class AddressRequestType { - private final Object value; - - private final int type; - - private AddressRequestType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AddressTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddressRequestType && equalTo((AddressRequestType) other); - } - - private boolean equalTo(AddressRequestType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AddressRequestType of(AddressTypeEnum value) { - return new AddressRequestType(value, 0); - } - - public static AddressRequestType of(String value) { - return new AddressRequestType(value, 1); - } - - public interface Visitor { - T visit(AddressTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AddressRequestType.class); - } - - @java.lang.Override - public AddressRequestType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AddressTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AddressType.java b/src/main/java/com/merge/api/resources/accounting/types/AddressType.java deleted file mode 100644 index 928177578..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AddressType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AddressType.Deserializer.class) -public final class AddressType { - private final Object value; - - private final int type; - - private AddressType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AddressTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddressType && equalTo((AddressType) other); - } - - private boolean equalTo(AddressType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AddressType of(AddressTypeEnum value) { - return new AddressType(value, 0); - } - - public static AddressType of(String value) { - return new AddressType(value, 1); - } - - public interface Visitor { - T visit(AddressTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AddressType.class); - } - - @java.lang.Override - public AddressType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AddressTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AsyncPostTask.java b/src/main/java/com/merge/api/resources/accounting/types/AsyncPostTask.java index ee1917812..67e10a18a 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/AsyncPostTask.java +++ b/src/main/java/com/merge/api/resources/accounting/types/AsyncPostTask.java @@ -19,21 +19,21 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AsyncPostTask.Builder.class) public final class AsyncPostTask { - private final AsyncPostTaskStatus status; + private final AsyncPostTaskStatusEnum status; private final AsyncPostTaskResult result; private final Map additionalProperties; private AsyncPostTask( - AsyncPostTaskStatus status, AsyncPostTaskResult result, Map additionalProperties) { + AsyncPostTaskStatusEnum status, AsyncPostTaskResult result, Map additionalProperties) { this.status = status; this.result = result; this.additionalProperties = additionalProperties; } @JsonProperty("status") - public AsyncPostTaskStatus getStatus() { + public AsyncPostTaskStatusEnum getStatus() { return status; } @@ -72,7 +72,7 @@ public static StatusStage builder() { } public interface StatusStage { - ResultStage status(@NotNull AsyncPostTaskStatus status); + ResultStage status(@NotNull AsyncPostTaskStatusEnum status); Builder from(AsyncPostTask other); } @@ -87,7 +87,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements StatusStage, ResultStage, _FinalStage { - private AsyncPostTaskStatus status; + private AsyncPostTaskStatusEnum status; private AsyncPostTaskResult result; @@ -105,7 +105,7 @@ public Builder from(AsyncPostTask other) { @java.lang.Override @JsonSetter("status") - public ResultStage status(@NotNull AsyncPostTaskStatus status) { + public ResultStage status(@NotNull AsyncPostTaskStatusEnum status) { this.status = status; return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/AsyncPostTaskStatus.java b/src/main/java/com/merge/api/resources/accounting/types/AsyncPostTaskStatus.java deleted file mode 100644 index ee8c3bf18..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AsyncPostTaskStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AsyncPostTaskStatus.Deserializer.class) -public final class AsyncPostTaskStatus { - private final Object value; - - private final int type; - - private AsyncPostTaskStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AsyncPostTaskStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AsyncPostTaskStatus && equalTo((AsyncPostTaskStatus) other); - } - - private boolean equalTo(AsyncPostTaskStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AsyncPostTaskStatus of(AsyncPostTaskStatusEnum value) { - return new AsyncPostTaskStatus(value, 0); - } - - public static AsyncPostTaskStatus of(String value) { - return new AsyncPostTaskStatus(value, 1); - } - - public interface Visitor { - T visit(AsyncPostTaskStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AsyncPostTaskStatus.class); - } - - @java.lang.Override - public AsyncPostTaskStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AsyncPostTaskStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AuditLogEvent.java b/src/main/java/com/merge/api/resources/accounting/types/AuditLogEvent.java index d0980b0d4..c63c806e5 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/AuditLogEvent.java +++ b/src/main/java/com/merge/api/resources/accounting/types/AuditLogEvent.java @@ -28,11 +28,11 @@ public final class AuditLogEvent { private final Optional userEmail; - private final AuditLogEventRole role; + private final RoleEnum role; private final String ipAddress; - private final AuditLogEventEventType eventType; + private final EventTypeEnum eventType; private final String eventDescription; @@ -44,9 +44,9 @@ private AuditLogEvent( Optional id, Optional userName, Optional userEmail, - AuditLogEventRole role, + RoleEnum role, String ipAddress, - AuditLogEventEventType eventType, + EventTypeEnum eventType, String eventDescription, Optional createdAt, Map additionalProperties) { @@ -94,7 +94,7 @@ public Optional getUserEmail() { * */ @JsonProperty("role") - public AuditLogEventRole getRole() { + public RoleEnum getRole() { return role; } @@ -115,6 +115,7 @@ public String getIpAddress() { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -150,7 +151,7 @@ public String getIpAddress() { * */ @JsonProperty("event_type") - public AuditLogEventEventType getEventType() { + public EventTypeEnum getEventType() { return eventType; } @@ -209,7 +210,7 @@ public static RoleStage builder() { } public interface RoleStage { - IpAddressStage role(@NotNull AuditLogEventRole role); + IpAddressStage role(@NotNull RoleEnum role); Builder from(AuditLogEvent other); } @@ -219,7 +220,7 @@ public interface IpAddressStage { } public interface EventTypeStage { - EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType); + EventDescriptionStage eventType(@NotNull EventTypeEnum eventType); } public interface EventDescriptionStage { @@ -249,11 +250,11 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements RoleStage, IpAddressStage, EventTypeStage, EventDescriptionStage, _FinalStage { - private AuditLogEventRole role; + private RoleEnum role; private String ipAddress; - private AuditLogEventEventType eventType; + private EventTypeEnum eventType; private String eventDescription; @@ -297,7 +298,7 @@ public Builder from(AuditLogEvent other) { */ @java.lang.Override @JsonSetter("role") - public IpAddressStage role(@NotNull AuditLogEventRole role) { + public IpAddressStage role(@NotNull RoleEnum role) { this.role = role; return this; } @@ -321,6 +322,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -358,7 +360,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { */ @java.lang.Override @JsonSetter("event_type") - public EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType) { + public EventDescriptionStage eventType(@NotNull EventTypeEnum eventType) { this.eventType = eventType; return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/AuditLogEventEventType.java b/src/main/java/com/merge/api/resources/accounting/types/AuditLogEventEventType.java deleted file mode 100644 index 730ca99cd..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AuditLogEventEventType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventEventType.Deserializer.class) -public final class AuditLogEventEventType { - private final Object value; - - private final int type; - - private AuditLogEventEventType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EventTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventEventType && equalTo((AuditLogEventEventType) other); - } - - private boolean equalTo(AuditLogEventEventType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventEventType of(EventTypeEnum value) { - return new AuditLogEventEventType(value, 0); - } - - public static AuditLogEventEventType of(String value) { - return new AuditLogEventEventType(value, 1); - } - - public interface Visitor { - T visit(EventTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventEventType.class); - } - - @java.lang.Override - public AuditLogEventEventType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EventTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/AuditLogEventRole.java b/src/main/java/com/merge/api/resources/accounting/types/AuditLogEventRole.java deleted file mode 100644 index e001a3967..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/AuditLogEventRole.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventRole.Deserializer.class) -public final class AuditLogEventRole { - private final Object value; - - private final int type; - - private AuditLogEventRole(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RoleEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventRole && equalTo((AuditLogEventRole) other); - } - - private boolean equalTo(AuditLogEventRole other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventRole of(RoleEnum value) { - return new AuditLogEventRole(value, 0); - } - - public static AuditLogEventRole of(String value) { - return new AuditLogEventRole(value, 1); - } - - public interface Visitor { - T visit(RoleEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventRole.class); - } - - @java.lang.Override - public AuditLogEventRole deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RoleEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/BalanceSheet.java b/src/main/java/com/merge/api/resources/accounting/types/BalanceSheet.java index 34e3ccd9b..25a46af81 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/BalanceSheet.java +++ b/src/main/java/com/merge/api/resources/accounting/types/BalanceSheet.java @@ -33,7 +33,7 @@ public final class BalanceSheet { private final Optional name; - private final Optional currency; + private final Optional currency; private final Optional company; @@ -63,7 +63,7 @@ private BalanceSheet( Optional createdAt, Optional modifiedAt, Optional name, - Optional currency, + Optional currency, Optional company, Optional date, Optional netAssets, @@ -443,7 +443,7 @@ public Optional getName() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -584,7 +584,7 @@ public static final class Builder { private Optional name = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional company = Optional.empty(); @@ -687,12 +687,12 @@ public Builder name(String name) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(BalanceSheetCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/BalanceSheetCompany.java b/src/main/java/com/merge/api/resources/accounting/types/BalanceSheetCompany.java index 3d914eecb..c49bf0cc9 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/BalanceSheetCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/BalanceSheetCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public BalanceSheetCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public BalanceSheetCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/BalanceSheetCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/BalanceSheetCurrency.java deleted file mode 100644 index 4f67911de..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/BalanceSheetCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = BalanceSheetCurrency.Deserializer.class) -public final class BalanceSheetCurrency { - private final Object value; - - private final int type; - - private BalanceSheetCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BalanceSheetCurrency && equalTo((BalanceSheetCurrency) other); - } - - private boolean equalTo(BalanceSheetCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static BalanceSheetCurrency of(TransactionCurrencyEnum value) { - return new BalanceSheetCurrency(value, 0); - } - - public static BalanceSheetCurrency of(String value) { - return new BalanceSheetCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(BalanceSheetCurrency.class); - } - - @java.lang.Override - public BalanceSheetCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccount.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccount.java index 71bab0d50..c5f39512d 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccount.java @@ -41,15 +41,15 @@ public final class BankFeedAccount { private final Optional targetAccountName; - private final Optional currency; + private final Optional currency; - private final Optional feedStatus; + private final Optional feedStatus; private final Optional feedStartDate; private final Optional sourceAccountBalance; - private final Optional accountType; + private final Optional accountType; private final Optional remoteWasDeleted; @@ -69,11 +69,11 @@ private BankFeedAccount( Optional sourceAccountName, Optional sourceAccountNumber, Optional targetAccountName, - Optional currency, - Optional feedStatus, + Optional currency, + Optional feedStatus, Optional feedStartDate, Optional sourceAccountBalance, - Optional accountType, + Optional accountType, Optional remoteWasDeleted, Optional> fieldMappings, Optional>>> remoteData, @@ -479,7 +479,7 @@ public Optional getTargetAccountName() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -491,7 +491,7 @@ public Optional getCurrency() { * */ @JsonProperty("feed_status") - public Optional getFeedStatus() { + public Optional getFeedStatus() { return feedStatus; } @@ -519,7 +519,7 @@ public Optional getSourceAccountBalance() { * */ @JsonProperty("account_type") - public Optional getAccountType() { + public Optional getAccountType() { return accountType; } @@ -623,15 +623,15 @@ public static final class Builder { private Optional targetAccountName = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); - private Optional feedStatus = Optional.empty(); + private Optional feedStatus = Optional.empty(); private Optional feedStartDate = Optional.empty(); private Optional sourceAccountBalance = Optional.empty(); - private Optional accountType = Optional.empty(); + private Optional accountType = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -765,23 +765,23 @@ public Builder targetAccountName(String targetAccountName) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(BankFeedAccountCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @JsonSetter(value = "feed_status", nulls = Nulls.SKIP) - public Builder feedStatus(Optional feedStatus) { + public Builder feedStatus(Optional feedStatus) { this.feedStatus = feedStatus; return this; } - public Builder feedStatus(BankFeedAccountFeedStatus feedStatus) { + public Builder feedStatus(FeedStatusEnum feedStatus) { this.feedStatus = Optional.ofNullable(feedStatus); return this; } @@ -809,12 +809,12 @@ public Builder sourceAccountBalance(Double sourceAccountBalance) { } @JsonSetter(value = "account_type", nulls = Nulls.SKIP) - public Builder accountType(Optional accountType) { + public Builder accountType(Optional accountType) { this.accountType = accountType; return this; } - public Builder accountType(BankFeedAccountAccountType accountType) { + public Builder accountType(BankFeedAccountAccountTypeEnum accountType) { this.accountType = Optional.ofNullable(accountType); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountAccountType.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountAccountType.java deleted file mode 100644 index cbb1e0c93..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountAccountType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = BankFeedAccountAccountType.Deserializer.class) -public final class BankFeedAccountAccountType { - private final Object value; - - private final int type; - - private BankFeedAccountAccountType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((BankFeedAccountAccountTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BankFeedAccountAccountType && equalTo((BankFeedAccountAccountType) other); - } - - private boolean equalTo(BankFeedAccountAccountType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static BankFeedAccountAccountType of(BankFeedAccountAccountTypeEnum value) { - return new BankFeedAccountAccountType(value, 0); - } - - public static BankFeedAccountAccountType of(String value) { - return new BankFeedAccountAccountType(value, 1); - } - - public interface Visitor { - T visit(BankFeedAccountAccountTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(BankFeedAccountAccountType.class); - } - - @java.lang.Override - public BankFeedAccountAccountType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, BankFeedAccountAccountTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountCurrency.java deleted file mode 100644 index bccc953fd..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = BankFeedAccountCurrency.Deserializer.class) -public final class BankFeedAccountCurrency { - private final Object value; - - private final int type; - - private BankFeedAccountCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BankFeedAccountCurrency && equalTo((BankFeedAccountCurrency) other); - } - - private boolean equalTo(BankFeedAccountCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static BankFeedAccountCurrency of(TransactionCurrencyEnum value) { - return new BankFeedAccountCurrency(value, 0); - } - - public static BankFeedAccountCurrency of(String value) { - return new BankFeedAccountCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(BankFeedAccountCurrency.class); - } - - @java.lang.Override - public BankFeedAccountCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountFeedStatus.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountFeedStatus.java deleted file mode 100644 index 0d770f053..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountFeedStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = BankFeedAccountFeedStatus.Deserializer.class) -public final class BankFeedAccountFeedStatus { - private final Object value; - - private final int type; - - private BankFeedAccountFeedStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((FeedStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BankFeedAccountFeedStatus && equalTo((BankFeedAccountFeedStatus) other); - } - - private boolean equalTo(BankFeedAccountFeedStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static BankFeedAccountFeedStatus of(FeedStatusEnum value) { - return new BankFeedAccountFeedStatus(value, 0); - } - - public static BankFeedAccountFeedStatus of(String value) { - return new BankFeedAccountFeedStatus(value, 1); - } - - public interface Visitor { - T visit(FeedStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(BankFeedAccountFeedStatus.class); - } - - @java.lang.Override - public BankFeedAccountFeedStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FeedStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequest.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequest.java index c11110e34..45700119c 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequest.java @@ -32,15 +32,15 @@ public final class BankFeedAccountRequest { private final Optional targetAccountName; - private final Optional currency; + private final Optional currency; - private final Optional feedStatus; + private final Optional feedStatus; private final Optional feedStartDate; private final Optional sourceAccountBalance; - private final Optional accountType; + private final Optional accountType; private final Optional> integrationParams; @@ -54,11 +54,11 @@ private BankFeedAccountRequest( Optional sourceAccountName, Optional sourceAccountNumber, Optional targetAccountName, - Optional currency, - Optional feedStatus, + Optional currency, + Optional feedStatus, Optional feedStartDate, Optional sourceAccountBalance, - Optional accountType, + Optional accountType, Optional> integrationParams, Optional> linkedAccountParams, Map additionalProperties) { @@ -429,7 +429,7 @@ public Optional getTargetAccountName() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -441,7 +441,7 @@ public Optional getCurrency() { * */ @JsonProperty("feed_status") - public Optional getFeedStatus() { + public Optional getFeedStatus() { return feedStatus; } @@ -469,7 +469,7 @@ public Optional getSourceAccountBalance() { * */ @JsonProperty("account_type") - public Optional getAccountType() { + public Optional getAccountType() { return accountType; } @@ -547,15 +547,15 @@ public static final class Builder { private Optional targetAccountName = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); - private Optional feedStatus = Optional.empty(); + private Optional feedStatus = Optional.empty(); private Optional feedStartDate = Optional.empty(); private Optional sourceAccountBalance = Optional.empty(); - private Optional accountType = Optional.empty(); + private Optional accountType = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -638,23 +638,23 @@ public Builder targetAccountName(String targetAccountName) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(BankFeedAccountRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @JsonSetter(value = "feed_status", nulls = Nulls.SKIP) - public Builder feedStatus(Optional feedStatus) { + public Builder feedStatus(Optional feedStatus) { this.feedStatus = feedStatus; return this; } - public Builder feedStatus(BankFeedAccountRequestFeedStatus feedStatus) { + public Builder feedStatus(FeedStatusEnum feedStatus) { this.feedStatus = Optional.ofNullable(feedStatus); return this; } @@ -682,12 +682,12 @@ public Builder sourceAccountBalance(Double sourceAccountBalance) { } @JsonSetter(value = "account_type", nulls = Nulls.SKIP) - public Builder accountType(Optional accountType) { + public Builder accountType(Optional accountType) { this.accountType = accountType; return this; } - public Builder accountType(BankFeedAccountRequestAccountType accountType) { + public Builder accountType(BankFeedAccountAccountTypeEnum accountType) { this.accountType = Optional.ofNullable(accountType); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequestAccountType.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequestAccountType.java deleted file mode 100644 index 89504c324..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequestAccountType.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = BankFeedAccountRequestAccountType.Deserializer.class) -public final class BankFeedAccountRequestAccountType { - private final Object value; - - private final int type; - - private BankFeedAccountRequestAccountType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((BankFeedAccountAccountTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BankFeedAccountRequestAccountType && equalTo((BankFeedAccountRequestAccountType) other); - } - - private boolean equalTo(BankFeedAccountRequestAccountType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static BankFeedAccountRequestAccountType of(BankFeedAccountAccountTypeEnum value) { - return new BankFeedAccountRequestAccountType(value, 0); - } - - public static BankFeedAccountRequestAccountType of(String value) { - return new BankFeedAccountRequestAccountType(value, 1); - } - - public interface Visitor { - T visit(BankFeedAccountAccountTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(BankFeedAccountRequestAccountType.class); - } - - @java.lang.Override - public BankFeedAccountRequestAccountType deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, BankFeedAccountAccountTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequestCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequestCurrency.java deleted file mode 100644 index ce8393fae..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequestCurrency.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = BankFeedAccountRequestCurrency.Deserializer.class) -public final class BankFeedAccountRequestCurrency { - private final Object value; - - private final int type; - - private BankFeedAccountRequestCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BankFeedAccountRequestCurrency && equalTo((BankFeedAccountRequestCurrency) other); - } - - private boolean equalTo(BankFeedAccountRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static BankFeedAccountRequestCurrency of(TransactionCurrencyEnum value) { - return new BankFeedAccountRequestCurrency(value, 0); - } - - public static BankFeedAccountRequestCurrency of(String value) { - return new BankFeedAccountRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(BankFeedAccountRequestCurrency.class); - } - - @java.lang.Override - public BankFeedAccountRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequestFeedStatus.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequestFeedStatus.java deleted file mode 100644 index 1d344ae85..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedAccountRequestFeedStatus.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = BankFeedAccountRequestFeedStatus.Deserializer.class) -public final class BankFeedAccountRequestFeedStatus { - private final Object value; - - private final int type; - - private BankFeedAccountRequestFeedStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((FeedStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BankFeedAccountRequestFeedStatus && equalTo((BankFeedAccountRequestFeedStatus) other); - } - - private boolean equalTo(BankFeedAccountRequestFeedStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static BankFeedAccountRequestFeedStatus of(FeedStatusEnum value) { - return new BankFeedAccountRequestFeedStatus(value, 0); - } - - public static BankFeedAccountRequestFeedStatus of(String value) { - return new BankFeedAccountRequestFeedStatus(value, 1); - } - - public interface Visitor { - T visit(FeedStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(BankFeedAccountRequestFeedStatus.class); - } - - @java.lang.Override - public BankFeedAccountRequestFeedStatus deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FeedStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransaction.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransaction.java index fe71aaff7..bcf75bc69 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransaction.java +++ b/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransaction.java @@ -43,7 +43,7 @@ public final class BankFeedTransaction { private final Optional payee; - private final Optional creditOrDebit; + private final Optional creditOrDebit; private final Optional sourceTransactionId; @@ -65,7 +65,7 @@ private BankFeedTransaction( Optional description, Optional transactionType, Optional payee, - Optional creditOrDebit, + Optional creditOrDebit, Optional sourceTransactionId, Optional remoteWasDeleted, Optional isProcessed, @@ -181,7 +181,7 @@ public Optional getPayee() { * */ @JsonProperty("credit_or_debit") - public Optional getCreditOrDebit() { + public Optional getCreditOrDebit() { return creditOrDebit; } @@ -291,7 +291,7 @@ public static final class Builder { private Optional payee = Optional.empty(); - private Optional creditOrDebit = Optional.empty(); + private Optional creditOrDebit = Optional.empty(); private Optional sourceTransactionId = Optional.empty(); @@ -445,12 +445,12 @@ public Builder payee(String payee) { } @JsonSetter(value = "credit_or_debit", nulls = Nulls.SKIP) - public Builder creditOrDebit(Optional creditOrDebit) { + public Builder creditOrDebit(Optional creditOrDebit) { this.creditOrDebit = creditOrDebit; return this; } - public Builder creditOrDebit(BankFeedTransactionCreditOrDebit creditOrDebit) { + public Builder creditOrDebit(CreditOrDebitEnum creditOrDebit) { this.creditOrDebit = Optional.ofNullable(creditOrDebit); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionBankFeedAccount.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionBankFeedAccount.java index 5f86f69cb..83c3cf2b7 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionBankFeedAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionBankFeedAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CreditOrDebitEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BankFeedTransactionCreditOrDebit && equalTo((BankFeedTransactionCreditOrDebit) other); - } - - private boolean equalTo(BankFeedTransactionCreditOrDebit other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static BankFeedTransactionCreditOrDebit of(CreditOrDebitEnum value) { - return new BankFeedTransactionCreditOrDebit(value, 0); - } - - public static BankFeedTransactionCreditOrDebit of(String value) { - return new BankFeedTransactionCreditOrDebit(value, 1); - } - - public interface Visitor { - T visit(CreditOrDebitEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(BankFeedTransactionCreditOrDebit.class); - } - - @java.lang.Override - public BankFeedTransactionCreditOrDebit deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CreditOrDebitEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionRequestRequest.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionRequestRequest.java index 66802f730..5dcf07004 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionRequestRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionRequestRequest.java @@ -36,7 +36,7 @@ public final class BankFeedTransactionRequestRequest { private final Optional payee; - private final Optional creditOrDebit; + private final Optional creditOrDebit; private final Optional sourceTransactionId; @@ -54,7 +54,7 @@ private BankFeedTransactionRequestRequest( Optional description, Optional transactionType, Optional payee, - Optional creditOrDebit, + Optional creditOrDebit, Optional sourceTransactionId, Optional> integrationParams, Optional> linkedAccountParams, @@ -137,7 +137,7 @@ public Optional getPayee() { * */ @JsonProperty("credit_or_debit") - public Optional getCreditOrDebit() { + public Optional getCreditOrDebit() { return creditOrDebit; } @@ -225,7 +225,7 @@ public static final class Builder { private Optional payee = Optional.empty(); - private Optional creditOrDebit = Optional.empty(); + private Optional creditOrDebit = Optional.empty(); private Optional sourceTransactionId = Optional.empty(); @@ -331,12 +331,12 @@ public Builder payee(String payee) { } @JsonSetter(value = "credit_or_debit", nulls = Nulls.SKIP) - public Builder creditOrDebit(Optional creditOrDebit) { + public Builder creditOrDebit(Optional creditOrDebit) { this.creditOrDebit = creditOrDebit; return this; } - public Builder creditOrDebit(BankFeedTransactionRequestRequestCreditOrDebit creditOrDebit) { + public Builder creditOrDebit(CreditOrDebitEnum creditOrDebit) { this.creditOrDebit = Optional.ofNullable(creditOrDebit); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionRequestRequestBankFeedAccount.java b/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionRequestRequestBankFeedAccount.java index 5e848f268..331fb7e24 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionRequestRequestBankFeedAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/BankFeedTransactionRequestRequestBankFeedAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,8 +80,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CreditOrDebitEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BankFeedTransactionRequestRequestCreditOrDebit - && equalTo((BankFeedTransactionRequestRequestCreditOrDebit) other); - } - - private boolean equalTo(BankFeedTransactionRequestRequestCreditOrDebit other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static BankFeedTransactionRequestRequestCreditOrDebit of(CreditOrDebitEnum value) { - return new BankFeedTransactionRequestRequestCreditOrDebit(value, 0); - } - - public static BankFeedTransactionRequestRequestCreditOrDebit of(String value) { - return new BankFeedTransactionRequestRequestCreditOrDebit(value, 1); - } - - public interface Visitor { - T visit(CreditOrDebitEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(BankFeedTransactionRequestRequestCreditOrDebit.class); - } - - @java.lang.Override - public BankFeedTransactionRequestRequestCreditOrDebit deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CreditOrDebitEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/CashFlowStatement.java b/src/main/java/com/merge/api/resources/accounting/types/CashFlowStatement.java index 506706222..bafb2e9ae 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CashFlowStatement.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CashFlowStatement.java @@ -33,7 +33,7 @@ public final class CashFlowStatement { private final Optional name; - private final Optional currency; + private final Optional currency; private final Optional company; @@ -67,7 +67,7 @@ private CashFlowStatement( Optional createdAt, Optional modifiedAt, Optional name, - Optional currency, + Optional currency, Optional company, Optional startPeriod, Optional endPeriod, @@ -451,7 +451,7 @@ public Optional getName() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -612,7 +612,7 @@ public static final class Builder { private Optional name = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional company = Optional.empty(); @@ -721,12 +721,12 @@ public Builder name(String name) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(CashFlowStatementCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/CashFlowStatementCompany.java b/src/main/java/com/merge/api/resources/accounting/types/CashFlowStatementCompany.java index 5c0ee3eac..0a80163b8 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CashFlowStatementCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CashFlowStatementCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CashFlowStatementCurrency && equalTo((CashFlowStatementCurrency) other); - } - - private boolean equalTo(CashFlowStatementCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static CashFlowStatementCurrency of(TransactionCurrencyEnum value) { - return new CashFlowStatementCurrency(value, 0); - } - - public static CashFlowStatementCurrency of(String value) { - return new CashFlowStatementCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(CashFlowStatementCurrency.class); - } - - @java.lang.Override - public CashFlowStatementCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/CompanyInfo.java b/src/main/java/com/merge/api/resources/accounting/types/CompanyInfo.java index 5f5c8467a..065be6cc6 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CompanyInfo.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CompanyInfo.java @@ -41,7 +41,7 @@ public final class CompanyInfo { private final Optional fiscalYearEndDay; - private final Optional currency; + private final Optional currency; private final Optional remoteCreatedAt; @@ -69,7 +69,7 @@ private CompanyInfo( Optional taxNumber, Optional fiscalYearEndMonth, Optional fiscalYearEndDay, - Optional currency, + Optional currency, Optional remoteCreatedAt, Optional>> urls, Optional> addresses, @@ -479,7 +479,7 @@ public Optional getFiscalYearEndDay() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -609,7 +609,7 @@ public static final class Builder { private Optional fiscalYearEndDay = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional remoteCreatedAt = Optional.empty(); @@ -751,12 +751,12 @@ public Builder fiscalYearEndDay(Integer fiscalYearEndDay) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(CompanyInfoCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/CompanyInfoCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/CompanyInfoCurrency.java deleted file mode 100644 index c6b38713b..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/CompanyInfoCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = CompanyInfoCurrency.Deserializer.class) -public final class CompanyInfoCurrency { - private final Object value; - - private final int type; - - private CompanyInfoCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CompanyInfoCurrency && equalTo((CompanyInfoCurrency) other); - } - - private boolean equalTo(CompanyInfoCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static CompanyInfoCurrency of(TransactionCurrencyEnum value) { - return new CompanyInfoCurrency(value, 0); - } - - public static CompanyInfoCurrency of(String value) { - return new CompanyInfoCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(CompanyInfoCurrency.class); - } - - @java.lang.Override - public CompanyInfoCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/Contact.java b/src/main/java/com/merge/api/resources/accounting/types/Contact.java index debefd4ec..f085f044c 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/Contact.java +++ b/src/main/java/com/merge/api/resources/accounting/types/Contact.java @@ -41,7 +41,7 @@ public final class Contact { private final Optional taxNumber; - private final Optional status; + private final Optional status; private final Optional currency; @@ -73,7 +73,7 @@ private Contact( Optional isCustomer, Optional emailAddress, Optional taxNumber, - Optional status, + Optional status, Optional currency, Optional remoteUpdatedAt, Optional company, @@ -183,7 +183,7 @@ public Optional getTaxNumber() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -336,7 +336,7 @@ public static final class Builder { private Optional taxNumber = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional currency = Optional.empty(); @@ -484,12 +484,12 @@ public Builder taxNumber(String taxNumber) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(ContactStatus status) { + public Builder status(Status7D1Enum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/ContactAddressesItem.java b/src/main/java/com/merge/api/resources/accounting/types/ContactAddressesItem.java index 61b65a1c3..31b51578b 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ContactAddressesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ContactAddressesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ContactAddressesItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ContactAddressesItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ContactRequest.java b/src/main/java/com/merge/api/resources/accounting/types/ContactRequest.java index 56fd570a1..cde736ae7 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ContactRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ContactRequest.java @@ -32,7 +32,7 @@ public final class ContactRequest { private final Optional taxNumber; - private final Optional status; + private final Optional status; private final Optional currency; @@ -56,7 +56,7 @@ private ContactRequest( Optional isCustomer, Optional emailAddress, Optional taxNumber, - Optional status, + Optional status, Optional currency, Optional company, Optional>> addresses, @@ -129,7 +129,7 @@ public Optional getTaxNumber() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -246,7 +246,7 @@ public static final class Builder { private Optional taxNumber = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional currency = Optional.empty(); @@ -340,12 +340,12 @@ public Builder taxNumber(String taxNumber) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(ContactRequestStatus status) { + public Builder status(Status7D1Enum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/ContactRequestAddressesItem.java b/src/main/java/com/merge/api/resources/accounting/types/ContactRequestAddressesItem.java index 3fa0d8882..e5f1ac3de 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ContactRequestAddressesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ContactRequestAddressesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Status7D1Enum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ContactRequestStatus && equalTo((ContactRequestStatus) other); - } - - private boolean equalTo(ContactRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ContactRequestStatus of(Status7D1Enum value) { - return new ContactRequestStatus(value, 0); - } - - public static ContactRequestStatus of(String value) { - return new ContactRequestStatus(value, 1); - } - - public interface Visitor { - T visit(Status7D1Enum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ContactRequestStatus.class); - } - - @java.lang.Override - public ContactRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, Status7D1Enum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/ContactStatus.java b/src/main/java/com/merge/api/resources/accounting/types/ContactStatus.java deleted file mode 100644 index 705de5726..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/ContactStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ContactStatus.Deserializer.class) -public final class ContactStatus { - private final Object value; - - private final int type; - - private ContactStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Status7D1Enum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ContactStatus && equalTo((ContactStatus) other); - } - - private boolean equalTo(ContactStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ContactStatus of(Status7D1Enum value) { - return new ContactStatus(value, 0); - } - - public static ContactStatus of(String value) { - return new ContactStatus(value, 1); - } - - public interface Visitor { - T visit(Status7D1Enum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ContactStatus.class); - } - - @java.lang.Override - public ContactStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, Status7D1Enum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNote.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNote.java index 4666752e4..17be759c6 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNote.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CreditNote.java @@ -33,7 +33,7 @@ public final class CreditNote { private final Optional transactionDate; - private final Optional status; + private final Optional status; private final Optional number; @@ -53,7 +53,7 @@ public final class CreditNote { private final Optional>> trackingCategories; - private final Optional currency; + private final Optional currency; private final Optional remoteCreatedAt; @@ -81,7 +81,7 @@ private CreditNote( Optional createdAt, Optional modifiedAt, Optional transactionDate, - Optional status, + Optional status, Optional number, Optional contact, Optional company, @@ -91,7 +91,7 @@ private CreditNote( Optional inclusiveOfTax, Optional> lineItems, Optional>> trackingCategories, - Optional currency, + Optional currency, Optional remoteCreatedAt, Optional remoteUpdatedAt, Optional>> payments, @@ -176,7 +176,7 @@ public Optional getTransactionDate() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -558,7 +558,7 @@ public Optional>> getTrackingCat * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -718,7 +718,7 @@ public static final class Builder { private Optional transactionDate = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional number = Optional.empty(); @@ -738,7 +738,7 @@ public static final class Builder { private Optional>> trackingCategories = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional remoteCreatedAt = Optional.empty(); @@ -848,12 +848,12 @@ public Builder transactionDate(OffsetDateTime transactionDate) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(CreditNoteStatus status) { + public Builder status(CreditNoteStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -959,12 +959,12 @@ public Builder trackingCategories(List currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(CreditNoteCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteAccountingPeriod.java index 7119b7f59..b0085eedf 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public CreditNoteCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public CreditNoteCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteContact.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteContact.java index 4d245b9a0..78c6a4ff9 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteContact.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public CreditNoteContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public CreditNoteContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteCurrency.java deleted file mode 100644 index 0bceaea2f..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = CreditNoteCurrency.Deserializer.class) -public final class CreditNoteCurrency { - private final Object value; - - private final int type; - - private CreditNoteCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CreditNoteCurrency && equalTo((CreditNoteCurrency) other); - } - - private boolean equalTo(CreditNoteCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static CreditNoteCurrency of(TransactionCurrencyEnum value) { - return new CreditNoteCurrency(value, 0); - } - - public static CreditNoteCurrency of(String value) { - return new CreditNoteCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(CreditNoteCurrency.class); - } - - @java.lang.Override - public CreditNoteCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteLineItemCompany.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteLineItemCompany.java index cf69565e5..c483f8184 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteLineItemCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteLineItemCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public CreditNoteLineItemItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public CreditNoteLineItemItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteLineItemRequestCompany.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteLineItemRequestCompany.java index 5142fcf9c..09f99d762 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteLineItemRequestCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteLineItemRequestCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public CreditNotePaymentsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public CreditNotePaymentsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequest.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequest.java index 2d5767360..49dbc4a67 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequest.java @@ -25,7 +25,7 @@ public final class CreditNoteRequest { private final Optional transactionDate; - private final Optional status; + private final Optional status; private final Optional number; @@ -45,7 +45,7 @@ public final class CreditNoteRequest { private final Optional>> trackingCategories; - private final Optional currency; + private final Optional currency; private final Optional>> payments; @@ -63,7 +63,7 @@ public final class CreditNoteRequest { private CreditNoteRequest( Optional transactionDate, - Optional status, + Optional status, Optional number, Optional contact, Optional company, @@ -73,7 +73,7 @@ private CreditNoteRequest( Optional inclusiveOfTax, Optional> lineItems, Optional>> trackingCategories, - Optional currency, + Optional currency, Optional>> payments, Optional>> appliedPayments, Optional accountingPeriod, @@ -119,7 +119,7 @@ public Optional getTransactionDate() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -501,7 +501,7 @@ public Optional>> getTrac * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -615,7 +615,7 @@ public static Builder builder() { public static final class Builder { private Optional transactionDate = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional number = Optional.empty(); @@ -635,7 +635,7 @@ public static final class Builder { private Optional>> trackingCategories = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional>> payments = Optional.empty(); @@ -688,12 +688,12 @@ public Builder transactionDate(OffsetDateTime transactionDate) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(CreditNoteRequestStatus status) { + public Builder status(CreditNoteStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -799,12 +799,12 @@ public Builder trackingCategories(List currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(CreditNoteRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestAccountingPeriod.java index 4d9b61fc3..1e6a495fd 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CreditNoteRequestCurrency && equalTo((CreditNoteRequestCurrency) other); - } - - private boolean equalTo(CreditNoteRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static CreditNoteRequestCurrency of(TransactionCurrencyEnum value) { - return new CreditNoteRequestCurrency(value, 0); - } - - public static CreditNoteRequestCurrency of(String value) { - return new CreditNoteRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(CreditNoteRequestCurrency.class); - } - - @java.lang.Override - public CreditNoteRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestLineItemsItem.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestLineItemsItem.java index e9748c2fb..aa4fdf190 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestLineItemsItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestLineItemsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CreditNoteStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CreditNoteRequestStatus && equalTo((CreditNoteRequestStatus) other); - } - - private boolean equalTo(CreditNoteRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static CreditNoteRequestStatus of(CreditNoteStatusEnum value) { - return new CreditNoteRequestStatus(value, 0); - } - - public static CreditNoteRequestStatus of(String value) { - return new CreditNoteRequestStatus(value, 1); - } - - public interface Visitor { - T visit(CreditNoteStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(CreditNoteRequestStatus.class); - } - - @java.lang.Override - public CreditNoteRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CreditNoteStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestTrackingCategoriesItem.java index c163388b9..3da5d1aa6 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteRequestTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CreditNoteStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CreditNoteStatus && equalTo((CreditNoteStatus) other); - } - - private boolean equalTo(CreditNoteStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static CreditNoteStatus of(CreditNoteStatusEnum value) { - return new CreditNoteStatus(value, 0); - } - - public static CreditNoteStatus of(String value) { - return new CreditNoteStatus(value, 1); - } - - public interface Visitor { - T visit(CreditNoteStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(CreditNoteStatus.class); - } - - @java.lang.Override - public CreditNoteStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CreditNoteStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteTrackingCategoriesItem.java index 446b2bb0e..4805a53d6 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/CreditNoteTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/CreditNoteTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer company; - private final EmployeeStatus status; + private final Status895Enum status; private final Optional remoteWasDeleted; @@ -65,7 +65,7 @@ private Employee( Optional employeeNumber, Optional emailAddress, Optional company, - EmployeeStatus status, + Status895Enum status, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -172,7 +172,7 @@ public Optional getCompany() { * */ @JsonProperty("status") - public EmployeeStatus getStatus() { + public Status895Enum getStatus() { return status; } @@ -251,7 +251,7 @@ public static StatusStage builder() { } public interface StatusStage { - _FinalStage status(@NotNull EmployeeStatus status); + _FinalStage status(@NotNull Status895Enum status); Builder from(Employee other); } @@ -314,7 +314,7 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements StatusStage, _FinalStage { - private EmployeeStatus status; + private Status895Enum status; private Optional> remoteData = Optional.empty(); @@ -376,7 +376,7 @@ public Builder from(Employee other) { */ @java.lang.Override @JsonSetter("status") - public _FinalStage status(@NotNull EmployeeStatus status) { + public _FinalStage status(@NotNull Status895Enum status) { this.status = status; return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/EmployeeCompany.java b/src/main/java/com/merge/api/resources/accounting/types/EmployeeCompany.java index 4682e5aa7..74ad2b562 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/EmployeeCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/EmployeeCompany.java @@ -7,7 +7,6 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.merge.api.core.ObjectMappers; @@ -30,11 +29,12 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); } else if (this.type == 1) { - return visitor.visit((JsonNode) this.value); + return visitor.visit((CompanyInfo) this.value); } throw new IllegalStateException("Failed to visit value. This should never happen."); } @@ -63,14 +63,14 @@ public static EmployeeCompany of(String value) { return new EmployeeCompany(value, 0); } - public static EmployeeCompany of(JsonNode value) { + public static EmployeeCompany of(CompanyInfo value) { return new EmployeeCompany(value, 1); } public interface Visitor { T visit(String value); - T visit(JsonNode value); + T visit(CompanyInfo value); } static final class Deserializer extends StdDeserializer { @@ -79,14 +79,14 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmployeeCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); } catch (IllegalArgumentException e) { } try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, JsonNode.class)); + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CompanyInfo.class)); } catch (IllegalArgumentException e) { } throw new JsonParseException(p, "Failed to deserialize"); diff --git a/src/main/java/com/merge/api/resources/accounting/types/EmployeeStatus.java b/src/main/java/com/merge/api/resources/accounting/types/EmployeeStatus.java deleted file mode 100644 index acc7f7206..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/EmployeeStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmployeeStatus.Deserializer.class) -public final class EmployeeStatus { - private final Object value; - - private final int type; - - private EmployeeStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Status895Enum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmployeeStatus && equalTo((EmployeeStatus) other); - } - - private boolean equalTo(EmployeeStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmployeeStatus of(Status895Enum value) { - return new EmployeeStatus(value, 0); - } - - public static EmployeeStatus of(String value) { - return new EmployeeStatus(value, 1); - } - - public interface Visitor { - T visit(Status895Enum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmployeeStatus.class); - } - - @java.lang.Override - public EmployeeStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, Status895Enum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/EventTypeEnum.java b/src/main/java/com/merge/api/resources/accounting/types/EventTypeEnum.java index 974340713..d5cbd8c05 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/EventTypeEnum.java +++ b/src/main/java/com/merge/api/resources/accounting/types/EventTypeEnum.java @@ -24,6 +24,8 @@ public enum EventTypeEnum { DELETED_LINKED_ACCOUNT("DELETED_LINKED_ACCOUNT"), + DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT("DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT"), + CREATED_DESTINATION("CREATED_DESTINATION"), DELETED_DESTINATION("DELETED_DESTINATION"), diff --git a/src/main/java/com/merge/api/resources/accounting/types/Expense.java b/src/main/java/com/merge/api/resources/accounting/types/Expense.java index a92c2ebb9..7e9987f79 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/Expense.java +++ b/src/main/java/com/merge/api/resources/accounting/types/Expense.java @@ -45,7 +45,7 @@ public final class Expense { private final Optional totalTaxAmount; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -85,7 +85,7 @@ private Expense( Optional totalAmount, Optional subTotal, Optional totalTaxAmount, - Optional currency, + Optional currency, Optional exchangeRate, Optional inclusiveOfTax, Optional company, @@ -523,7 +523,7 @@ public Optional getTotalTaxAmount() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -708,7 +708,7 @@ public static final class Builder { private Optional totalTaxAmount = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -889,12 +889,12 @@ public Builder totalTaxAmount(Double totalTaxAmount) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(ExpenseCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseAccount.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseAccount.java index 317bc9118..9a8fc3fbd 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseAccountingPeriod.java index 91b02c345..880f40b4c 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public ExpenseAccountingPeriod deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseAccountingPeriod deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseCompany.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseCompany.java index 990d6e5f3..1ce7d2bb0 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseContact.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseContact.java index 8fcf5a29a..9af429042 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseContact.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseCurrency.java deleted file mode 100644 index cb524cfb5..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ExpenseCurrency.Deserializer.class) -public final class ExpenseCurrency { - private final Object value; - - private final int type; - - private ExpenseCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ExpenseCurrency && equalTo((ExpenseCurrency) other); - } - - private boolean equalTo(ExpenseCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ExpenseCurrency of(TransactionCurrencyEnum value) { - return new ExpenseCurrency(value, 0); - } - - public static ExpenseCurrency of(String value) { - return new ExpenseCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ExpenseCurrency.class); - } - - @java.lang.Override - public ExpenseCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseEmployee.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseEmployee.java index 3fb529ae1..ea5396708 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseEmployee.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLine.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLine.java index cea0ed66e..45daec40d 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLine.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLine.java @@ -42,7 +42,7 @@ public final class ExpenseLine { private final Optional employee; - private final Optional currency; + private final Optional currency; private final Optional account; @@ -69,7 +69,7 @@ private ExpenseLine( Optional>> trackingCategories, Optional company, Optional employee, - Optional currency, + Optional currency, Optional account, Optional contact, Optional description, @@ -483,7 +483,7 @@ public Optional getEmployee() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -619,7 +619,7 @@ public static final class Builder { private Optional employee = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional account = Optional.empty(); @@ -771,12 +771,12 @@ public Builder employee(ExpenseLineEmployee employee) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(ExpenseLineCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineAccount.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineAccount.java index f155ebd80..0dc0630bc 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseLineAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseLineAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineContact.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineContact.java index f6774174b..2e766879c 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineContact.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseLineContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseLineContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineCurrency.java deleted file mode 100644 index 9af6a80f4..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ExpenseLineCurrency.Deserializer.class) -public final class ExpenseLineCurrency { - private final Object value; - - private final int type; - - private ExpenseLineCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ExpenseLineCurrency && equalTo((ExpenseLineCurrency) other); - } - - private boolean equalTo(ExpenseLineCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ExpenseLineCurrency of(TransactionCurrencyEnum value) { - return new ExpenseLineCurrency(value, 0); - } - - public static ExpenseLineCurrency of(String value) { - return new ExpenseLineCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ExpenseLineCurrency.class); - } - - @java.lang.Override - public ExpenseLineCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineEmployee.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineEmployee.java index 31a66e744..6f4eae274 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineEmployee.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseLineEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseLineEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineItem.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineItem.java index 1a55e8102..5b7d4fc6f 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseLineItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseLineItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequest.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequest.java index 7b94fcca9..1cf9dd42b 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequest.java @@ -36,7 +36,7 @@ public final class ExpenseLineRequest { private final Optional employee; - private final Optional currency; + private final Optional currency; private final Optional account; @@ -64,7 +64,7 @@ private ExpenseLineRequest( Optional>> trackingCategories, Optional company, Optional employee, - Optional currency, + Optional currency, Optional account, Optional contact, Optional description, @@ -458,7 +458,7 @@ public Optional getEmployee() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -594,7 +594,7 @@ public static final class Builder { private Optional employee = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional account = Optional.empty(); @@ -716,12 +716,12 @@ public Builder employee(ExpenseLineRequestEmployee employee) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(ExpenseLineRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestAccount.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestAccount.java index 86efa6eea..fb67f2da5 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ExpenseLineRequestCurrency && equalTo((ExpenseLineRequestCurrency) other); - } - - private boolean equalTo(ExpenseLineRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ExpenseLineRequestCurrency of(TransactionCurrencyEnum value) { - return new ExpenseLineRequestCurrency(value, 0); - } - - public static ExpenseLineRequestCurrency of(String value) { - return new ExpenseLineRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ExpenseLineRequestCurrency.class); - } - - @java.lang.Override - public ExpenseLineRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestEmployee.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestEmployee.java index 9f57db9a9..85f53a370 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestEmployee.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public ExpenseLineRequestItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseLineRequestItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestTrackingCategoriesItem.java index b7422d7c0..b20654cd3 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseLineRequestTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer totalTaxAmount; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -68,7 +68,7 @@ private ExpenseRequest( Optional totalAmount, Optional subTotal, Optional totalTaxAmount, - Optional currency, + Optional currency, Optional exchangeRate, Optional inclusiveOfTax, Optional company, @@ -462,7 +462,7 @@ public Optional getTotalTaxAmount() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -617,7 +617,7 @@ public static final class Builder { private Optional totalTaxAmount = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -735,12 +735,12 @@ public Builder totalTaxAmount(Double totalTaxAmount) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(ExpenseRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestAccount.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestAccount.java index 55a80a266..52b79b804 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseRequestAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseRequestAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestAccountingPeriod.java index 7474e1f72..1740608b0 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseRequestCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseRequestCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestContact.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestContact.java index bb8bc9ac9..09f7b1318 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestContact.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ExpenseRequestContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseRequestContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestCurrency.java deleted file mode 100644 index 9c6b78e18..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ExpenseRequestCurrency.Deserializer.class) -public final class ExpenseRequestCurrency { - private final Object value; - - private final int type; - - private ExpenseRequestCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ExpenseRequestCurrency && equalTo((ExpenseRequestCurrency) other); - } - - private boolean equalTo(ExpenseRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ExpenseRequestCurrency of(TransactionCurrencyEnum value) { - return new ExpenseRequestCurrency(value, 0); - } - - public static ExpenseRequestCurrency of(String value) { - return new ExpenseRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ExpenseRequestCurrency.class); - } - - @java.lang.Override - public ExpenseRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestEmployee.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestEmployee.java index fc8874a6a..646f0b832 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestEmployee.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public ExpenseRequestEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ExpenseRequestEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestTrackingCategoriesItem.java index a6dad3125..6727075a5 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ExpenseRequestTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer> employee; + private final Optional> paymentMethod; + + private final Optional> paymentTerm; + private final Map additionalProperties; private ExternalTargetFieldApiResponse( @@ -90,6 +94,8 @@ private ExternalTargetFieldApiResponse( Optional> generalLedgerTransaction, Optional> bankFeedAccount, Optional> employee, + Optional> paymentMethod, + Optional> paymentTerm, Map additionalProperties) { this.account = account; this.accountingAttachment = accountingAttachment; @@ -113,6 +119,8 @@ private ExternalTargetFieldApiResponse( this.generalLedgerTransaction = generalLedgerTransaction; this.bankFeedAccount = bankFeedAccount; this.employee = employee; + this.paymentMethod = paymentMethod; + this.paymentTerm = paymentTerm; this.additionalProperties = additionalProperties; } @@ -226,6 +234,16 @@ public Optional> getEmployee() { return employee; } + @JsonProperty("PaymentMethod") + public Optional> getPaymentMethod() { + return paymentMethod; + } + + @JsonProperty("PaymentTerm") + public Optional> getPaymentTerm() { + return paymentTerm; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -259,7 +277,9 @@ private boolean equalTo(ExternalTargetFieldApiResponse other) { && accountingPeriod.equals(other.accountingPeriod) && generalLedgerTransaction.equals(other.generalLedgerTransaction) && bankFeedAccount.equals(other.bankFeedAccount) - && employee.equals(other.employee); + && employee.equals(other.employee) + && paymentMethod.equals(other.paymentMethod) + && paymentTerm.equals(other.paymentTerm); } @java.lang.Override @@ -286,7 +306,9 @@ public int hashCode() { this.accountingPeriod, this.generalLedgerTransaction, this.bankFeedAccount, - this.employee); + this.employee, + this.paymentMethod, + this.paymentTerm); } @java.lang.Override @@ -344,6 +366,10 @@ public static final class Builder { private Optional> employee = Optional.empty(); + private Optional> paymentMethod = Optional.empty(); + + private Optional> paymentTerm = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -372,6 +398,8 @@ public Builder from(ExternalTargetFieldApiResponse other) { generalLedgerTransaction(other.getGeneralLedgerTransaction()); bankFeedAccount(other.getBankFeedAccount()); employee(other.getEmployee()); + paymentMethod(other.getPaymentMethod()); + paymentTerm(other.getPaymentTerm()); return this; } @@ -617,6 +645,28 @@ public Builder employee(List employee) { return this; } + @JsonSetter(value = "PaymentMethod", nulls = Nulls.SKIP) + public Builder paymentMethod(Optional> paymentMethod) { + this.paymentMethod = paymentMethod; + return this; + } + + public Builder paymentMethod(List paymentMethod) { + this.paymentMethod = Optional.ofNullable(paymentMethod); + return this; + } + + @JsonSetter(value = "PaymentTerm", nulls = Nulls.SKIP) + public Builder paymentTerm(Optional> paymentTerm) { + this.paymentTerm = paymentTerm; + return this; + } + + public Builder paymentTerm(List paymentTerm) { + this.paymentTerm = Optional.ofNullable(paymentTerm); + return this; + } + public ExternalTargetFieldApiResponse build() { return new ExternalTargetFieldApiResponse( account, @@ -641,6 +691,8 @@ public ExternalTargetFieldApiResponse build() { generalLedgerTransaction, bankFeedAccount, employee, + paymentMethod, + paymentTerm, additionalProperties); } } diff --git a/src/main/java/com/merge/api/resources/accounting/types/FieldMappingApiInstanceResponse.java b/src/main/java/com/merge/api/resources/accounting/types/FieldMappingApiInstanceResponse.java index 2888091a9..030686e2f 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/FieldMappingApiInstanceResponse.java +++ b/src/main/java/com/merge/api/resources/accounting/types/FieldMappingApiInstanceResponse.java @@ -65,6 +65,10 @@ public final class FieldMappingApiInstanceResponse { private final Optional> employee; + private final Optional> paymentMethod; + + private final Optional> paymentTerm; + private final Map additionalProperties; private FieldMappingApiInstanceResponse( @@ -90,6 +94,8 @@ private FieldMappingApiInstanceResponse( Optional> generalLedgerTransaction, Optional> bankFeedAccount, Optional> employee, + Optional> paymentMethod, + Optional> paymentTerm, Map additionalProperties) { this.account = account; this.accountingAttachment = accountingAttachment; @@ -113,6 +119,8 @@ private FieldMappingApiInstanceResponse( this.generalLedgerTransaction = generalLedgerTransaction; this.bankFeedAccount = bankFeedAccount; this.employee = employee; + this.paymentMethod = paymentMethod; + this.paymentTerm = paymentTerm; this.additionalProperties = additionalProperties; } @@ -226,6 +234,16 @@ public Optional> getEmployee() { return employee; } + @JsonProperty("PaymentMethod") + public Optional> getPaymentMethod() { + return paymentMethod; + } + + @JsonProperty("PaymentTerm") + public Optional> getPaymentTerm() { + return paymentTerm; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -259,7 +277,9 @@ private boolean equalTo(FieldMappingApiInstanceResponse other) { && accountingPeriod.equals(other.accountingPeriod) && generalLedgerTransaction.equals(other.generalLedgerTransaction) && bankFeedAccount.equals(other.bankFeedAccount) - && employee.equals(other.employee); + && employee.equals(other.employee) + && paymentMethod.equals(other.paymentMethod) + && paymentTerm.equals(other.paymentTerm); } @java.lang.Override @@ -286,7 +306,9 @@ public int hashCode() { this.accountingPeriod, this.generalLedgerTransaction, this.bankFeedAccount, - this.employee); + this.employee, + this.paymentMethod, + this.paymentTerm); } @java.lang.Override @@ -344,6 +366,10 @@ public static final class Builder { private Optional> employee = Optional.empty(); + private Optional> paymentMethod = Optional.empty(); + + private Optional> paymentTerm = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -372,6 +398,8 @@ public Builder from(FieldMappingApiInstanceResponse other) { generalLedgerTransaction(other.getGeneralLedgerTransaction()); bankFeedAccount(other.getBankFeedAccount()); employee(other.getEmployee()); + paymentMethod(other.getPaymentMethod()); + paymentTerm(other.getPaymentTerm()); return this; } @@ -617,6 +645,28 @@ public Builder employee(List employee) { return this; } + @JsonSetter(value = "PaymentMethod", nulls = Nulls.SKIP) + public Builder paymentMethod(Optional> paymentMethod) { + this.paymentMethod = paymentMethod; + return this; + } + + public Builder paymentMethod(List paymentMethod) { + this.paymentMethod = Optional.ofNullable(paymentMethod); + return this; + } + + @JsonSetter(value = "PaymentTerm", nulls = Nulls.SKIP) + public Builder paymentTerm(Optional> paymentTerm) { + this.paymentTerm = paymentTerm; + return this; + } + + public Builder paymentTerm(List paymentTerm) { + this.paymentTerm = Optional.ofNullable(paymentTerm); + return this; + } + public FieldMappingApiInstanceResponse build() { return new FieldMappingApiInstanceResponse( account, @@ -641,6 +691,8 @@ public FieldMappingApiInstanceResponse build() { generalLedgerTransaction, bankFeedAccount, employee, + paymentMethod, + paymentTerm, additionalProperties); } } diff --git a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransaction.java b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransaction.java index 9bf7c2de1..54a041974 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransaction.java +++ b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransaction.java @@ -33,7 +33,7 @@ public final class GeneralLedgerTransaction { private final Optional underlyingTransactionRemoteId; - private final Optional underlyingTransactionType; + private final Optional underlyingTransactionType; private final Optional accountingPeriod; @@ -64,7 +64,7 @@ private GeneralLedgerTransaction( Optional createdAt, Optional modifiedAt, Optional underlyingTransactionRemoteId, - Optional underlyingTransactionType, + Optional underlyingTransactionType, Optional accountingPeriod, Optional company, Optional remoteUpdatedAt, @@ -145,7 +145,7 @@ public Optional getUnderlyingTransactionRemoteId() { * */ @JsonProperty("underlying_transaction_type") - public Optional getUnderlyingTransactionType() { + public Optional getUnderlyingTransactionType() { return underlyingTransactionType; } @@ -293,8 +293,7 @@ public static final class Builder { private Optional underlyingTransactionRemoteId = Optional.empty(); - private Optional underlyingTransactionType = - Optional.empty(); + private Optional underlyingTransactionType = Optional.empty(); private Optional accountingPeriod = Optional.empty(); @@ -399,14 +398,12 @@ public Builder underlyingTransactionRemoteId(String underlyingTransactionRemoteI } @JsonSetter(value = "underlying_transaction_type", nulls = Nulls.SKIP) - public Builder underlyingTransactionType( - Optional underlyingTransactionType) { + public Builder underlyingTransactionType(Optional underlyingTransactionType) { this.underlyingTransactionType = underlyingTransactionType; return this; } - public Builder underlyingTransactionType( - GeneralLedgerTransactionUnderlyingTransactionType underlyingTransactionType) { + public Builder underlyingTransactionType(UnderlyingTransactionTypeEnum underlyingTransactionType) { this.underlyingTransactionType = Optional.ofNullable(underlyingTransactionType); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionAccountingPeriod.java index 585b60170..90bc76169 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -80,7 +81,7 @@ static final class Deserializer extends StdDeserializer contact; - private final Optional baseCurrency; + private final Optional baseCurrency; - private final Optional transactionCurrency; + private final Optional transactionCurrency; private final Optional exchangeRate; private final Optional description; - private final Optional> trackingCategories; + private final Optional> trackingCategories; private final String debitAmount; @@ -75,11 +75,11 @@ private GeneralLedgerTransactionLine( Optional company, Optional employee, Optional contact, - Optional baseCurrency, - Optional transactionCurrency, + Optional baseCurrency, + Optional transactionCurrency, Optional exchangeRate, Optional description, - Optional> trackingCategories, + Optional> trackingCategories, String debitAmount, String creditAmount, Optional item, @@ -475,7 +475,7 @@ public Optional getContact() { * */ @JsonProperty("base_currency") - public Optional getBaseCurrency() { + public Optional getBaseCurrency() { return baseCurrency; } @@ -791,7 +791,7 @@ public Optional getBaseCurrency() { * */ @JsonProperty("transaction_currency") - public Optional getTransactionCurrency() { + public Optional getTransactionCurrency() { return transactionCurrency; } @@ -812,7 +812,7 @@ public Optional getDescription() { } @JsonProperty("tracking_categories") - public Optional> getTrackingCategories() { + public Optional> getTrackingCategories() { return trackingCategories; } @@ -975,13 +975,13 @@ public interface _FinalStage { _FinalStage contact(GeneralLedgerTransactionLineContact contact); - _FinalStage baseCurrency(Optional baseCurrency); + _FinalStage baseCurrency(Optional baseCurrency); - _FinalStage baseCurrency(GeneralLedgerTransactionLineBaseCurrency baseCurrency); + _FinalStage baseCurrency(TransactionCurrencyEnum baseCurrency); - _FinalStage transactionCurrency(Optional transactionCurrency); + _FinalStage transactionCurrency(Optional transactionCurrency); - _FinalStage transactionCurrency(GeneralLedgerTransactionLineTransactionCurrency transactionCurrency); + _FinalStage transactionCurrency(TransactionCurrencyEnum transactionCurrency); _FinalStage exchangeRate(Optional exchangeRate); @@ -991,9 +991,10 @@ public interface _FinalStage { _FinalStage description(String description); - _FinalStage trackingCategories(Optional> trackingCategories); + _FinalStage trackingCategories( + Optional> trackingCategories); - _FinalStage trackingCategories(List trackingCategories); + _FinalStage trackingCategories(List trackingCategories); _FinalStage item(Optional item); @@ -1029,15 +1030,16 @@ public static final class Builder private Optional item = Optional.empty(); - private Optional> trackingCategories = Optional.empty(); + private Optional> trackingCategories = + Optional.empty(); private Optional description = Optional.empty(); private Optional exchangeRate = Optional.empty(); - private Optional transactionCurrency = Optional.empty(); + private Optional transactionCurrency = Optional.empty(); - private Optional baseCurrency = Optional.empty(); + private Optional baseCurrency = Optional.empty(); private Optional contact = Optional.empty(); @@ -1157,14 +1159,16 @@ public _FinalStage item(Optional item) { } @java.lang.Override - public _FinalStage trackingCategories(List trackingCategories) { + public _FinalStage trackingCategories( + List trackingCategories) { this.trackingCategories = Optional.ofNullable(trackingCategories); return this; } @java.lang.Override @JsonSetter(value = "tracking_categories", nulls = Nulls.SKIP) - public _FinalStage trackingCategories(Optional> trackingCategories) { + public _FinalStage trackingCategories( + Optional> trackingCategories) { this.trackingCategories = trackingCategories; return this; } @@ -1516,15 +1520,14 @@ public _FinalStage exchangeRate(Optional exchangeRate) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage transactionCurrency(GeneralLedgerTransactionLineTransactionCurrency transactionCurrency) { + public _FinalStage transactionCurrency(TransactionCurrencyEnum transactionCurrency) { this.transactionCurrency = Optional.ofNullable(transactionCurrency); return this; } @java.lang.Override @JsonSetter(value = "transaction_currency", nulls = Nulls.SKIP) - public _FinalStage transactionCurrency( - Optional transactionCurrency) { + public _FinalStage transactionCurrency(Optional transactionCurrency) { this.transactionCurrency = transactionCurrency; return this; } @@ -1842,14 +1845,14 @@ public _FinalStage transactionCurrency( * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage baseCurrency(GeneralLedgerTransactionLineBaseCurrency baseCurrency) { + public _FinalStage baseCurrency(TransactionCurrencyEnum baseCurrency) { this.baseCurrency = Optional.ofNullable(baseCurrency); return this; } @java.lang.Override @JsonSetter(value = "base_currency", nulls = Nulls.SKIP) - public _FinalStage baseCurrency(Optional baseCurrency) { + public _FinalStage baseCurrency(Optional baseCurrency) { this.baseCurrency = baseCurrency; return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineAccount.java b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineAccount.java index 58277e520..a5c777e7b 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GeneralLedgerTransactionLineBaseCurrency - && equalTo((GeneralLedgerTransactionLineBaseCurrency) other); - } - - private boolean equalTo(GeneralLedgerTransactionLineBaseCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static GeneralLedgerTransactionLineBaseCurrency of(TransactionCurrencyEnum value) { - return new GeneralLedgerTransactionLineBaseCurrency(value, 0); - } - - public static GeneralLedgerTransactionLineBaseCurrency of(String value) { - return new GeneralLedgerTransactionLineBaseCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(GeneralLedgerTransactionLineBaseCurrency.class); - } - - @java.lang.Override - public GeneralLedgerTransactionLineBaseCurrency deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineCompany.java b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineCompany.java index 854398b5e..24809bb57 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((TrackingCategory) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GeneralLedgerTransactionLineTrackingCategoriesItem + && equalTo((GeneralLedgerTransactionLineTrackingCategoriesItem) other); + } + + private boolean equalTo(GeneralLedgerTransactionLineTrackingCategoriesItem other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static GeneralLedgerTransactionLineTrackingCategoriesItem of(String value) { + return new GeneralLedgerTransactionLineTrackingCategoriesItem(value, 0); + } + + public static GeneralLedgerTransactionLineTrackingCategoriesItem of(TrackingCategory value) { + return new GeneralLedgerTransactionLineTrackingCategoriesItem(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(TrackingCategory value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(GeneralLedgerTransactionLineTrackingCategoriesItem.class); + } + + @java.lang.Override + public GeneralLedgerTransactionLineTrackingCategoriesItem deserialize( + JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, TrackingCategory.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineTransactionCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineTransactionCurrency.java deleted file mode 100644 index 087815b85..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionLineTransactionCurrency.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = GeneralLedgerTransactionLineTransactionCurrency.Deserializer.class) -public final class GeneralLedgerTransactionLineTransactionCurrency { - private final Object value; - - private final int type; - - private GeneralLedgerTransactionLineTransactionCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GeneralLedgerTransactionLineTransactionCurrency - && equalTo((GeneralLedgerTransactionLineTransactionCurrency) other); - } - - private boolean equalTo(GeneralLedgerTransactionLineTransactionCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static GeneralLedgerTransactionLineTransactionCurrency of(TransactionCurrencyEnum value) { - return new GeneralLedgerTransactionLineTransactionCurrency(value, 0); - } - - public static GeneralLedgerTransactionLineTransactionCurrency of(String value) { - return new GeneralLedgerTransactionLineTransactionCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(GeneralLedgerTransactionLineTransactionCurrency.class); - } - - @java.lang.Override - public GeneralLedgerTransactionLineTransactionCurrency deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionTrackingCategoriesItem.java index 9a44eebbc..643ddf353 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/GeneralLedgerTransactionTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((UnderlyingTransactionTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GeneralLedgerTransactionUnderlyingTransactionType - && equalTo((GeneralLedgerTransactionUnderlyingTransactionType) other); - } - - private boolean equalTo(GeneralLedgerTransactionUnderlyingTransactionType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static GeneralLedgerTransactionUnderlyingTransactionType of(UnderlyingTransactionTypeEnum value) { - return new GeneralLedgerTransactionUnderlyingTransactionType(value, 0); - } - - public static GeneralLedgerTransactionUnderlyingTransactionType of(String value) { - return new GeneralLedgerTransactionUnderlyingTransactionType(value, 1); - } - - public interface Visitor { - T visit(UnderlyingTransactionTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(GeneralLedgerTransactionUnderlyingTransactionType.class); - } - - @java.lang.Override - public GeneralLedgerTransactionUnderlyingTransactionType deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, UnderlyingTransactionTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/IncomeStatement.java b/src/main/java/com/merge/api/resources/accounting/types/IncomeStatement.java index d9be0bf41..a20ca0ee2 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/IncomeStatement.java +++ b/src/main/java/com/merge/api/resources/accounting/types/IncomeStatement.java @@ -33,7 +33,7 @@ public final class IncomeStatement { private final Optional name; - private final Optional currency; + private final Optional currency; private final Optional company; @@ -69,7 +69,7 @@ private IncomeStatement( Optional createdAt, Optional modifiedAt, Optional name, - Optional currency, + Optional currency, Optional company, Optional startPeriod, Optional endPeriod, @@ -455,7 +455,7 @@ public Optional getName() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -623,7 +623,7 @@ public static final class Builder { private Optional name = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional company = Optional.empty(); @@ -735,12 +735,12 @@ public Builder name(String name) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(IncomeStatementCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/IncomeStatementCompany.java b/src/main/java/com/merge/api/resources/accounting/types/IncomeStatementCompany.java index dfd4905bf..24ed825aa 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/IncomeStatementCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/IncomeStatementCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public IncomeStatementCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public IncomeStatementCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/IncomeStatementCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/IncomeStatementCurrency.java deleted file mode 100644 index 3abf574f9..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/IncomeStatementCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = IncomeStatementCurrency.Deserializer.class) -public final class IncomeStatementCurrency { - private final Object value; - - private final int type; - - private IncomeStatementCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IncomeStatementCurrency && equalTo((IncomeStatementCurrency) other); - } - - private boolean equalTo(IncomeStatementCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static IncomeStatementCurrency of(TransactionCurrencyEnum value) { - return new IncomeStatementCurrency(value, 0); - } - - public static IncomeStatementCurrency of(String value) { - return new IncomeStatementCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(IncomeStatementCurrency.class); - } - - @java.lang.Override - public IncomeStatementCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/Invoice.java b/src/main/java/com/merge/api/resources/accounting/types/Invoice.java index 20dde74cb..8546727e9 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/Invoice.java +++ b/src/main/java/com/merge/api/resources/accounting/types/Invoice.java @@ -31,7 +31,7 @@ public final class Invoice { private final Optional modifiedAt; - private final Optional type; + private final Optional type; private final Optional contact; @@ -49,15 +49,17 @@ public final class Invoice { private final Optional employee; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; + private final Optional paymentTerm; + private final Optional totalDiscount; private final Optional subTotal; - private final Optional status; + private final Optional status; private final Optional totalTaxAmount; @@ -100,7 +102,7 @@ private Invoice( Optional remoteId, Optional createdAt, Optional modifiedAt, - Optional type, + Optional type, Optional contact, Optional number, Optional issueDate, @@ -109,11 +111,12 @@ private Invoice( Optional memo, Optional company, Optional employee, - Optional currency, + Optional currency, Optional exchangeRate, + Optional paymentTerm, Optional totalDiscount, Optional subTotal, - Optional status, + Optional status, Optional totalTaxAmount, Optional totalAmount, Optional balance, @@ -147,6 +150,7 @@ private Invoice( this.employee = employee; this.currency = currency; this.exchangeRate = exchangeRate; + this.paymentTerm = paymentTerm; this.totalDiscount = totalDiscount; this.subTotal = subTotal; this.status = status; @@ -207,7 +211,7 @@ public Optional getModifiedAt() { * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -587,7 +591,7 @@ public Optional getEmployee() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -599,6 +603,14 @@ public Optional getExchangeRate() { return exchangeRate; } + /** + * @return The payment term that applies to this transaction. + */ + @JsonProperty("payment_term") + public Optional getPaymentTerm() { + return paymentTerm; + } + /** * @return The total discounts applied to the total cost. */ @@ -627,7 +639,7 @@ public Optional getSubTotal() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -776,6 +788,7 @@ private boolean equalTo(Invoice other) { && employee.equals(other.employee) && currency.equals(other.currency) && exchangeRate.equals(other.exchangeRate) + && paymentTerm.equals(other.paymentTerm) && totalDiscount.equals(other.totalDiscount) && subTotal.equals(other.subTotal) && status.equals(other.status) @@ -816,6 +829,7 @@ public int hashCode() { this.employee, this.currency, this.exchangeRate, + this.paymentTerm, this.totalDiscount, this.subTotal, this.status, @@ -857,7 +871,7 @@ public static final class Builder { private Optional modifiedAt = Optional.empty(); - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); private Optional contact = Optional.empty(); @@ -875,15 +889,17 @@ public static final class Builder { private Optional employee = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); + private Optional paymentTerm = Optional.empty(); + private Optional totalDiscount = Optional.empty(); private Optional subTotal = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional totalTaxAmount = Optional.empty(); @@ -940,6 +956,7 @@ public Builder from(Invoice other) { employee(other.getEmployee()); currency(other.getCurrency()); exchangeRate(other.getExchangeRate()); + paymentTerm(other.getPaymentTerm()); totalDiscount(other.getTotalDiscount()); subTotal(other.getSubTotal()); status(other.getStatus()); @@ -1008,12 +1025,12 @@ public Builder modifiedAt(OffsetDateTime modifiedAt) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(InvoiceType type) { + public Builder type(InvoiceTypeEnum type) { this.type = Optional.ofNullable(type); return this; } @@ -1107,12 +1124,12 @@ public Builder employee(InvoiceEmployee employee) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(InvoiceCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @@ -1128,6 +1145,17 @@ public Builder exchangeRate(String exchangeRate) { return this; } + @JsonSetter(value = "payment_term", nulls = Nulls.SKIP) + public Builder paymentTerm(Optional paymentTerm) { + this.paymentTerm = paymentTerm; + return this; + } + + public Builder paymentTerm(InvoicePaymentTerm paymentTerm) { + this.paymentTerm = Optional.ofNullable(paymentTerm); + return this; + } + @JsonSetter(value = "total_discount", nulls = Nulls.SKIP) public Builder totalDiscount(Optional totalDiscount) { this.totalDiscount = totalDiscount; @@ -1151,12 +1179,12 @@ public Builder subTotal(Double subTotal) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(InvoiceStatus status) { + public Builder status(InvoiceStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -1365,6 +1393,7 @@ public Invoice build() { employee, currency, exchangeRate, + paymentTerm, totalDiscount, subTotal, status, diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceAccountingPeriod.java index 9ae01ab84..1d0a392a2 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public InvoiceAccountingPeriod deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoiceAccountingPeriod deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceAppliedCreditNotesItem.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceAppliedCreditNotesItem.java index 5b9706a94..690a2f6e5 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceAppliedCreditNotesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceAppliedCreditNotesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public InvoiceCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoiceCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceContact.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceContact.java index bfa96d977..a8784ae51 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceContact.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public InvoiceContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoiceContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceCurrency.java deleted file mode 100644 index fd3d7ba7f..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = InvoiceCurrency.Deserializer.class) -public final class InvoiceCurrency { - private final Object value; - - private final int type; - - private InvoiceCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvoiceCurrency && equalTo((InvoiceCurrency) other); - } - - private boolean equalTo(InvoiceCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static InvoiceCurrency of(TransactionCurrencyEnum value) { - return new InvoiceCurrency(value, 0); - } - - public static InvoiceCurrency of(String value) { - return new InvoiceCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(InvoiceCurrency.class); - } - - @java.lang.Override - public InvoiceCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceEmployee.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceEmployee.java index cf97d6c69..22ce6f396 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceEmployee.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public InvoiceEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoiceEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItem.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItem.java index 8a4571e27..e24dc4f37 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItem.java @@ -41,7 +41,7 @@ public final class InvoiceLineItem { private final Optional employee; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -75,7 +75,7 @@ private InvoiceLineItem( Optional quantity, Optional totalAmount, Optional employee, - Optional currency, + Optional currency, Optional exchangeRate, Optional item, Optional account, @@ -491,7 +491,7 @@ public Optional getEmployee() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -648,7 +648,7 @@ public static final class Builder { private Optional employee = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -799,12 +799,12 @@ public Builder employee(InvoiceLineItemEmployee employee) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(InvoiceLineItemCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemAccount.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemAccount.java index 9ac9f30d3..ad1b29686 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public InvoiceLineItemAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoiceLineItemAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemCurrency.java deleted file mode 100644 index 8edef2e88..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = InvoiceLineItemCurrency.Deserializer.class) -public final class InvoiceLineItemCurrency { - private final Object value; - - private final int type; - - private InvoiceLineItemCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvoiceLineItemCurrency && equalTo((InvoiceLineItemCurrency) other); - } - - private boolean equalTo(InvoiceLineItemCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static InvoiceLineItemCurrency of(TransactionCurrencyEnum value) { - return new InvoiceLineItemCurrency(value, 0); - } - - public static InvoiceLineItemCurrency of(String value) { - return new InvoiceLineItemCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(InvoiceLineItemCurrency.class); - } - - @java.lang.Override - public InvoiceLineItemCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemEmployee.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemEmployee.java index 910fbc88b..5b3ccd539 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemEmployee.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public InvoiceLineItemEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoiceLineItemEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemItem.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemItem.java index d4dcea829..e2e2fcc0e 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public InvoiceLineItemItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoiceLineItemItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequest.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequest.java index 23a54607d..81f08d8bd 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequest.java @@ -34,7 +34,7 @@ public final class InvoiceLineItemRequest { private final Optional employee; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -65,7 +65,7 @@ private InvoiceLineItemRequest( Optional quantity, Optional totalAmount, Optional employee, - Optional currency, + Optional currency, Optional exchangeRate, Optional item, Optional account, @@ -457,7 +457,7 @@ public Optional getEmployee() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -599,7 +599,7 @@ public static final class Builder { private Optional employee = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -715,12 +715,12 @@ public Builder employee(InvoiceLineItemRequestEmployee employee) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(InvoiceLineItemRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequestAccount.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequestAccount.java index 43804c753..c513898c5 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequestAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvoiceLineItemRequestCurrency && equalTo((InvoiceLineItemRequestCurrency) other); - } - - private boolean equalTo(InvoiceLineItemRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static InvoiceLineItemRequestCurrency of(TransactionCurrencyEnum value) { - return new InvoiceLineItemRequestCurrency(value, 0); - } - - public static InvoiceLineItemRequestCurrency of(String value) { - return new InvoiceLineItemRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(InvoiceLineItemRequestCurrency.class); - } - - @java.lang.Override - public InvoiceLineItemRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequestEmployee.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequestEmployee.java index 1d043e04d..fe1df289b 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequestEmployee.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceLineItemRequestEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((PaymentTerm) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InvoicePaymentTerm && equalTo((InvoicePaymentTerm) other); + } + + private boolean equalTo(InvoicePaymentTerm other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static InvoicePaymentTerm of(String value) { + return new InvoicePaymentTerm(value, 0); + } + + public static InvoicePaymentTerm of(PaymentTerm value) { + return new InvoicePaymentTerm(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(PaymentTerm value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(InvoicePaymentTerm.class); + } + + @java.lang.Override + public InvoicePaymentTerm deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentTerm.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoicePaymentsItem.java b/src/main/java/com/merge/api/resources/accounting/types/InvoicePaymentsItem.java index 0edb30e83..a66a444ff 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoicePaymentsItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoicePaymentsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public InvoicePaymentsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoicePaymentsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoicePurchaseOrdersItem.java b/src/main/java/com/merge/api/resources/accounting/types/InvoicePurchaseOrdersItem.java index 55156a0c8..9bc859104 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoicePurchaseOrdersItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoicePurchaseOrdersItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer type; + private final Optional type; private final Optional contact; @@ -39,11 +39,11 @@ public final class InvoiceRequest { private final Optional memo; - private final Optional status; + private final Optional status; private final Optional company; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -51,6 +51,8 @@ public final class InvoiceRequest { private final Optional subTotal; + private final Optional paymentTerm; + private final Optional totalTaxAmount; private final Optional inclusiveOfTax; @@ -76,7 +78,7 @@ public final class InvoiceRequest { private final Map additionalProperties; private InvoiceRequest( - Optional type, + Optional type, Optional contact, Optional number, Optional issueDate, @@ -84,12 +86,13 @@ private InvoiceRequest( Optional paidOnDate, Optional employee, Optional memo, - Optional status, + Optional status, Optional company, - Optional currency, + Optional currency, Optional exchangeRate, Optional totalDiscount, Optional subTotal, + Optional paymentTerm, Optional totalTaxAmount, Optional inclusiveOfTax, Optional totalAmount, @@ -116,6 +119,7 @@ private InvoiceRequest( this.exchangeRate = exchangeRate; this.totalDiscount = totalDiscount; this.subTotal = subTotal; + this.paymentTerm = paymentTerm; this.totalTaxAmount = totalTaxAmount; this.inclusiveOfTax = inclusiveOfTax; this.totalAmount = totalAmount; @@ -138,7 +142,7 @@ private InvoiceRequest( * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -210,7 +214,7 @@ public Optional getMemo() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -534,7 +538,7 @@ public Optional getCompany() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -562,6 +566,14 @@ public Optional getSubTotal() { return subTotal; } + /** + * @return The payment term that applies to this transaction. + */ + @JsonProperty("payment_term") + public Optional getPaymentTerm() { + return paymentTerm; + } + /** * @return The total amount being paid in taxes. */ @@ -658,6 +670,7 @@ private boolean equalTo(InvoiceRequest other) { && exchangeRate.equals(other.exchangeRate) && totalDiscount.equals(other.totalDiscount) && subTotal.equals(other.subTotal) + && paymentTerm.equals(other.paymentTerm) && totalTaxAmount.equals(other.totalTaxAmount) && inclusiveOfTax.equals(other.inclusiveOfTax) && totalAmount.equals(other.totalAmount) @@ -688,6 +701,7 @@ public int hashCode() { this.exchangeRate, this.totalDiscount, this.subTotal, + this.paymentTerm, this.totalTaxAmount, this.inclusiveOfTax, this.totalAmount, @@ -712,7 +726,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); private Optional contact = Optional.empty(); @@ -728,11 +742,11 @@ public static final class Builder { private Optional memo = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional company = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -740,6 +754,8 @@ public static final class Builder { private Optional subTotal = Optional.empty(); + private Optional paymentTerm = Optional.empty(); + private Optional totalTaxAmount = Optional.empty(); private Optional inclusiveOfTax = Optional.empty(); @@ -782,6 +798,7 @@ public Builder from(InvoiceRequest other) { exchangeRate(other.getExchangeRate()); totalDiscount(other.getTotalDiscount()); subTotal(other.getSubTotal()); + paymentTerm(other.getPaymentTerm()); totalTaxAmount(other.getTotalTaxAmount()); inclusiveOfTax(other.getInclusiveOfTax()); totalAmount(other.getTotalAmount()); @@ -797,12 +814,12 @@ public Builder from(InvoiceRequest other) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(InvoiceRequestType type) { + public Builder type(InvoiceTypeEnum type) { this.type = Optional.ofNullable(type); return this; } @@ -885,12 +902,12 @@ public Builder memo(String memo) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(InvoiceRequestStatus status) { + public Builder status(InvoiceStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -907,12 +924,12 @@ public Builder company(InvoiceRequestCompany company) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(InvoiceRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @@ -950,6 +967,17 @@ public Builder subTotal(Double subTotal) { return this; } + @JsonSetter(value = "payment_term", nulls = Nulls.SKIP) + public Builder paymentTerm(Optional paymentTerm) { + this.paymentTerm = paymentTerm; + return this; + } + + public Builder paymentTerm(InvoiceRequestPaymentTerm paymentTerm) { + this.paymentTerm = Optional.ofNullable(paymentTerm); + return this; + } + @JsonSetter(value = "total_tax_amount", nulls = Nulls.SKIP) public Builder totalTaxAmount(Optional totalTaxAmount) { this.totalTaxAmount = totalTaxAmount; @@ -1088,6 +1116,7 @@ public InvoiceRequest build() { exchangeRate, totalDiscount, subTotal, + paymentTerm, totalTaxAmount, inclusiveOfTax, totalAmount, diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestCompany.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestCompany.java index c2359870a..7cccbf9fe 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public InvoiceRequestCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoiceRequestCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestContact.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestContact.java index 5dcca38bc..c7acf9467 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestContact.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public InvoiceRequestContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoiceRequestContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestCurrency.java deleted file mode 100644 index 8a6ceb853..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = InvoiceRequestCurrency.Deserializer.class) -public final class InvoiceRequestCurrency { - private final Object value; - - private final int type; - - private InvoiceRequestCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvoiceRequestCurrency && equalTo((InvoiceRequestCurrency) other); - } - - private boolean equalTo(InvoiceRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static InvoiceRequestCurrency of(TransactionCurrencyEnum value) { - return new InvoiceRequestCurrency(value, 0); - } - - public static InvoiceRequestCurrency of(String value) { - return new InvoiceRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(InvoiceRequestCurrency.class); - } - - @java.lang.Override - public InvoiceRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestEmployee.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestEmployee.java index 47c557740..271407bc2 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestEmployee.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public InvoiceRequestEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public InvoiceRequestEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestPaymentTerm.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestPaymentTerm.java new file mode 100644 index 000000000..da275043c --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestPaymentTerm.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.merge.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = InvoiceRequestPaymentTerm.Deserializer.class) +public final class InvoiceRequestPaymentTerm { + private final Object value; + + private final int type; + + private InvoiceRequestPaymentTerm(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((PaymentTerm) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof InvoiceRequestPaymentTerm && equalTo((InvoiceRequestPaymentTerm) other); + } + + private boolean equalTo(InvoiceRequestPaymentTerm other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static InvoiceRequestPaymentTerm of(String value) { + return new InvoiceRequestPaymentTerm(value, 0); + } + + public static InvoiceRequestPaymentTerm of(PaymentTerm value) { + return new InvoiceRequestPaymentTerm(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(PaymentTerm value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(InvoiceRequestPaymentTerm.class); + } + + @java.lang.Override + public InvoiceRequestPaymentTerm deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentTerm.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestPaymentsItem.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestPaymentsItem.java index ff2e92129..93bdabe6a 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestPaymentsItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestPaymentsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((InvoiceStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvoiceRequestStatus && equalTo((InvoiceRequestStatus) other); - } - - private boolean equalTo(InvoiceRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static InvoiceRequestStatus of(InvoiceStatusEnum value) { - return new InvoiceRequestStatus(value, 0); - } - - public static InvoiceRequestStatus of(String value) { - return new InvoiceRequestStatus(value, 1); - } - - public interface Visitor { - T visit(InvoiceStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(InvoiceRequestStatus.class); - } - - @java.lang.Override - public InvoiceRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, InvoiceStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestTrackingCategoriesItem.java index d28bde3ad..aebe3a117 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceRequestTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((InvoiceTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvoiceRequestType && equalTo((InvoiceRequestType) other); - } - - private boolean equalTo(InvoiceRequestType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static InvoiceRequestType of(InvoiceTypeEnum value) { - return new InvoiceRequestType(value, 0); - } - - public static InvoiceRequestType of(String value) { - return new InvoiceRequestType(value, 1); - } - - public interface Visitor { - T visit(InvoiceTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(InvoiceRequestType.class); - } - - @java.lang.Override - public InvoiceRequestType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, InvoiceTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceStatus.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceStatus.java deleted file mode 100644 index eedfe8107..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = InvoiceStatus.Deserializer.class) -public final class InvoiceStatus { - private final Object value; - - private final int type; - - private InvoiceStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((InvoiceStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvoiceStatus && equalTo((InvoiceStatus) other); - } - - private boolean equalTo(InvoiceStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static InvoiceStatus of(InvoiceStatusEnum value) { - return new InvoiceStatus(value, 0); - } - - public static InvoiceStatus of(String value) { - return new InvoiceStatus(value, 1); - } - - public interface Visitor { - T visit(InvoiceStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(InvoiceStatus.class); - } - - @java.lang.Override - public InvoiceStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, InvoiceStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/InvoiceTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/InvoiceTrackingCategoriesItem.java index a0cc9d076..b901ac001 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/InvoiceTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/InvoiceTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((InvoiceTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvoiceType && equalTo((InvoiceType) other); - } - - private boolean equalTo(InvoiceType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static InvoiceType of(InvoiceTypeEnum value) { - return new InvoiceType(value, 0); - } - - public static InvoiceType of(String value) { - return new InvoiceType(value, 1); - } - - public interface Visitor { - T visit(InvoiceTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(InvoiceType.class); - } - - @java.lang.Override - public InvoiceType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, InvoiceTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/Issue.java b/src/main/java/com/merge/api/resources/accounting/types/Issue.java index 380d42135..57bfd760b 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/Issue.java +++ b/src/main/java/com/merge/api/resources/accounting/types/Issue.java @@ -26,7 +26,7 @@ public final class Issue { private final Optional id; - private final Optional status; + private final Optional status; private final String errorDescription; @@ -44,7 +44,7 @@ public final class Issue { private Issue( Optional id, - Optional status, + Optional status, String errorDescription, Optional> endUser, Optional firstIncidentTime, @@ -76,7 +76,7 @@ public Optional getId() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -167,9 +167,9 @@ public interface _FinalStage { _FinalStage id(String id); - _FinalStage status(Optional status); + _FinalStage status(Optional status); - _FinalStage status(IssueStatus status); + _FinalStage status(IssueStatusEnum status); _FinalStage endUser(Optional> endUser); @@ -206,7 +206,7 @@ public static final class Builder implements ErrorDescriptionStage, _FinalStage private Optional> endUser = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional id = Optional.empty(); @@ -309,14 +309,14 @@ public _FinalStage endUser(Optional> endUser) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage status(IssueStatus status) { + public _FinalStage status(IssueStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @java.lang.Override @JsonSetter(value = "status", nulls = Nulls.SKIP) - public _FinalStage status(Optional status) { + public _FinalStage status(Optional status) { this.status = status; return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/IssueStatus.java b/src/main/java/com/merge/api/resources/accounting/types/IssueStatus.java deleted file mode 100644 index bf658d0ad..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/IssueStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = IssueStatus.Deserializer.class) -public final class IssueStatus { - private final Object value; - - private final int type; - - private IssueStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((IssueStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IssueStatus && equalTo((IssueStatus) other); - } - - private boolean equalTo(IssueStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static IssueStatus of(IssueStatusEnum value) { - return new IssueStatus(value, 0); - } - - public static IssueStatus of(String value) { - return new IssueStatus(value, 1); - } - - public interface Visitor { - T visit(IssueStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(IssueStatus.class); - } - - @java.lang.Override - public IssueStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, IssueStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/Item.java b/src/main/java/com/merge/api/resources/accounting/types/Item.java index 6371309fe..faf437563 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/Item.java +++ b/src/main/java/com/merge/api/resources/accounting/types/Item.java @@ -33,7 +33,7 @@ public final class Item { private final Optional name; - private final Optional status; + private final Optional status; private final Optional unitPrice; @@ -65,7 +65,7 @@ private Item( Optional createdAt, Optional modifiedAt, Optional name, - Optional status, + Optional status, Optional unitPrice, Optional purchasePrice, Optional purchaseAccount, @@ -143,7 +143,7 @@ public Optional getName() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -303,7 +303,7 @@ public static final class Builder { private Optional name = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional unitPrice = Optional.empty(); @@ -409,12 +409,12 @@ public Builder name(String name) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(ItemStatus status) { + public Builder status(Status7D1Enum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/ItemCompany.java b/src/main/java/com/merge/api/resources/accounting/types/ItemCompany.java index 96f67343e..3637a5eee 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ItemCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ItemCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ItemCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ItemCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ItemPurchaseAccount.java b/src/main/java/com/merge/api/resources/accounting/types/ItemPurchaseAccount.java index 7ff419ea4..b72862ed5 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ItemPurchaseAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ItemPurchaseAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ItemPurchaseAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ItemPurchaseAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ItemPurchaseTaxRate.java b/src/main/java/com/merge/api/resources/accounting/types/ItemPurchaseTaxRate.java index 8d8130ac0..229fb1e23 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ItemPurchaseTaxRate.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ItemPurchaseTaxRate.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ItemPurchaseTaxRate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ItemPurchaseTaxRate deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ItemSalesAccount.java b/src/main/java/com/merge/api/resources/accounting/types/ItemSalesAccount.java index 0561c1eef..010699f09 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ItemSalesAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ItemSalesAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ItemSalesAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ItemSalesAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ItemSalesTaxRate.java b/src/main/java/com/merge/api/resources/accounting/types/ItemSalesTaxRate.java index 4a67beb71..9b9cf00b2 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/ItemSalesTaxRate.java +++ b/src/main/java/com/merge/api/resources/accounting/types/ItemSalesTaxRate.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ItemSalesTaxRate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ItemSalesTaxRate deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/ItemStatus.java b/src/main/java/com/merge/api/resources/accounting/types/ItemStatus.java deleted file mode 100644 index e94f5d5a8..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/ItemStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ItemStatus.Deserializer.class) -public final class ItemStatus { - private final Object value; - - private final int type; - - private ItemStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Status7D1Enum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ItemStatus && equalTo((ItemStatus) other); - } - - private boolean equalTo(ItemStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ItemStatus of(Status7D1Enum value) { - return new ItemStatus(value, 0); - } - - public static ItemStatus of(String value) { - return new ItemStatus(value, 1); - } - - public interface Visitor { - T visit(Status7D1Enum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ItemStatus.class); - } - - @java.lang.Override - public ItemStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, Status7D1Enum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalEntry.java b/src/main/java/com/merge/api/resources/accounting/types/JournalEntry.java index 9f95858e4..94d710f95 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalEntry.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalEntry.java @@ -39,7 +39,7 @@ public final class JournalEntry { private final Optional memo; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -55,7 +55,7 @@ public final class JournalEntry { private final Optional remoteWasDeleted; - private final Optional postingStatus; + private final Optional postingStatus; private final Optional accountingPeriod; @@ -80,7 +80,7 @@ private JournalEntry( Optional>> payments, Optional>> appliedPayments, Optional memo, - Optional currency, + Optional currency, Optional exchangeRate, Optional company, Optional inclusiveOfTax, @@ -88,7 +88,7 @@ private JournalEntry( Optional journalNumber, Optional>> trackingCategories, Optional remoteWasDeleted, - Optional postingStatus, + Optional postingStatus, Optional accountingPeriod, Optional remoteCreatedAt, Optional remoteUpdatedAt, @@ -495,7 +495,7 @@ public Optional getMemo() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -557,7 +557,7 @@ public Optional getRemoteWasDeleted() { * */ @JsonProperty("posting_status") - public Optional getPostingStatus() { + public Optional getPostingStatus() { return postingStatus; } @@ -692,7 +692,7 @@ public static final class Builder { private Optional memo = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -708,7 +708,7 @@ public static final class Builder { private Optional remoteWasDeleted = Optional.empty(); - private Optional postingStatus = Optional.empty(); + private Optional postingStatus = Optional.empty(); private Optional accountingPeriod = Optional.empty(); @@ -843,12 +843,12 @@ public Builder memo(String memo) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(JournalEntryCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @@ -932,12 +932,12 @@ public Builder remoteWasDeleted(Boolean remoteWasDeleted) { } @JsonSetter(value = "posting_status", nulls = Nulls.SKIP) - public Builder postingStatus(Optional postingStatus) { + public Builder postingStatus(Optional postingStatus) { this.postingStatus = postingStatus; return this; } - public Builder postingStatus(JournalEntryPostingStatus postingStatus) { + public Builder postingStatus(PostingStatusEnum postingStatus) { this.postingStatus = Optional.ofNullable(postingStatus); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryAccountingPeriod.java index 0b7de18bd..a783f8877 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public JournalEntryCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public JournalEntryCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryCurrency.java deleted file mode 100644 index f3f6b6447..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = JournalEntryCurrency.Deserializer.class) -public final class JournalEntryCurrency { - private final Object value; - - private final int type; - - private JournalEntryCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof JournalEntryCurrency && equalTo((JournalEntryCurrency) other); - } - - private boolean equalTo(JournalEntryCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static JournalEntryCurrency of(TransactionCurrencyEnum value) { - return new JournalEntryCurrency(value, 0); - } - - public static JournalEntryCurrency of(String value) { - return new JournalEntryCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(JournalEntryCurrency.class); - } - - @java.lang.Override - public JournalEntryCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryPaymentsItem.java b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryPaymentsItem.java index 288b19f5e..8b263c8fb 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryPaymentsItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryPaymentsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PostingStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof JournalEntryPostingStatus && equalTo((JournalEntryPostingStatus) other); - } - - private boolean equalTo(JournalEntryPostingStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static JournalEntryPostingStatus of(PostingStatusEnum value) { - return new JournalEntryPostingStatus(value, 0); - } - - public static JournalEntryPostingStatus of(String value) { - return new JournalEntryPostingStatus(value, 1); - } - - public interface Visitor { - T visit(PostingStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(JournalEntryPostingStatus.class); - } - - @java.lang.Override - public JournalEntryPostingStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PostingStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequest.java b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequest.java index ac43bbd64..8a1953fac 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequest.java @@ -29,7 +29,7 @@ public final class JournalEntryRequest { private final Optional memo; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -43,7 +43,7 @@ public final class JournalEntryRequest { private final Optional journalNumber; - private final Optional postingStatus; + private final Optional postingStatus; private final Optional> integrationParams; @@ -57,14 +57,14 @@ private JournalEntryRequest( Optional transactionDate, Optional>> payments, Optional memo, - Optional currency, + Optional currency, Optional exchangeRate, Optional company, Optional>> trackingCategories, Optional inclusiveOfTax, Optional> lines, Optional journalNumber, - Optional postingStatus, + Optional postingStatus, Optional> integrationParams, Optional> linkedAccountParams, Optional> remoteFields, @@ -422,7 +422,7 @@ public Optional getMemo() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -476,7 +476,7 @@ public Optional getJournalNumber() { * */ @JsonProperty("posting_status") - public Optional getPostingStatus() { + public Optional getPostingStatus() { return postingStatus; } @@ -559,7 +559,7 @@ public static final class Builder { private Optional memo = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -574,7 +574,7 @@ public static final class Builder { private Optional journalNumber = Optional.empty(); - private Optional postingStatus = Optional.empty(); + private Optional postingStatus = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -639,12 +639,12 @@ public Builder memo(String memo) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(JournalEntryRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @@ -718,12 +718,12 @@ public Builder journalNumber(String journalNumber) { } @JsonSetter(value = "posting_status", nulls = Nulls.SKIP) - public Builder postingStatus(Optional postingStatus) { + public Builder postingStatus(Optional postingStatus) { this.postingStatus = postingStatus; return this; } - public Builder postingStatus(JournalEntryRequestPostingStatus postingStatus) { + public Builder postingStatus(PostingStatusEnum postingStatus) { this.postingStatus = Optional.ofNullable(postingStatus); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestCompany.java b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestCompany.java index fd82d2f7c..9cb6d9c9b 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof JournalEntryRequestCurrency && equalTo((JournalEntryRequestCurrency) other); - } - - private boolean equalTo(JournalEntryRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static JournalEntryRequestCurrency of(TransactionCurrencyEnum value) { - return new JournalEntryRequestCurrency(value, 0); - } - - public static JournalEntryRequestCurrency of(String value) { - return new JournalEntryRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(JournalEntryRequestCurrency.class); - } - - @java.lang.Override - public JournalEntryRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestPaymentsItem.java b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestPaymentsItem.java index 69be80c43..bff1d73cc 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestPaymentsItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestPaymentsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PostingStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof JournalEntryRequestPostingStatus && equalTo((JournalEntryRequestPostingStatus) other); - } - - private boolean equalTo(JournalEntryRequestPostingStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static JournalEntryRequestPostingStatus of(PostingStatusEnum value) { - return new JournalEntryRequestPostingStatus(value, 0); - } - - public static JournalEntryRequestPostingStatus of(String value) { - return new JournalEntryRequestPostingStatus(value, 1); - } - - public interface Visitor { - T visit(PostingStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(JournalEntryRequestPostingStatus.class); - } - - @java.lang.Override - public JournalEntryRequestPostingStatus deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PostingStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestTrackingCategoriesItem.java index fe2c4883d..5fbff9e64 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalEntryRequestTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer>> trackingCategories; - private final Optional currency; + private final Optional currency; private final Optional company; @@ -67,7 +67,7 @@ private JournalLine( Optional netAmount, Optional trackingCategory, Optional>> trackingCategories, - Optional currency, + Optional currency, Optional company, Optional employee, Optional contact, @@ -464,7 +464,7 @@ public Optional>> getTrackingCa * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -603,7 +603,7 @@ public static final class Builder { private Optional>> trackingCategories = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional company = Optional.empty(); @@ -737,12 +737,12 @@ public Builder trackingCategories(List currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(JournalLineCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalLineAccount.java b/src/main/java/com/merge/api/resources/accounting/types/JournalLineAccount.java index 32d989466..ef36061df 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalLineAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalLineAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public JournalLineAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public JournalLineAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalLineCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/JournalLineCurrency.java deleted file mode 100644 index 1e2b025c8..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalLineCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = JournalLineCurrency.Deserializer.class) -public final class JournalLineCurrency { - private final Object value; - - private final int type; - - private JournalLineCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof JournalLineCurrency && equalTo((JournalLineCurrency) other); - } - - private boolean equalTo(JournalLineCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static JournalLineCurrency of(TransactionCurrencyEnum value) { - return new JournalLineCurrency(value, 0); - } - - public static JournalLineCurrency of(String value) { - return new JournalLineCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(JournalLineCurrency.class); - } - - @java.lang.Override - public JournalLineCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequest.java b/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequest.java index 40bb844a1..5f80b10ca 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequest.java @@ -32,7 +32,7 @@ public final class JournalLineRequest { private final Optional>> trackingCategories; - private final Optional currency; + private final Optional currency; private final Optional company; @@ -60,7 +60,7 @@ private JournalLineRequest( Optional netAmount, Optional trackingCategory, Optional>> trackingCategories, - Optional currency, + Optional currency, Optional company, Optional employee, Optional contact, @@ -435,7 +435,7 @@ public Optional>> getTra * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -567,7 +567,7 @@ public static final class Builder { private Optional>> trackingCategories = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional company = Optional.empty(); @@ -668,12 +668,12 @@ public Builder trackingCategories(List currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(JournalLineRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequestAccount.java b/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequestAccount.java index d4feb2498..48244853f 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequestAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof JournalLineRequestCurrency && equalTo((JournalLineRequestCurrency) other); - } - - private boolean equalTo(JournalLineRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static JournalLineRequestCurrency of(TransactionCurrencyEnum value) { - return new JournalLineRequestCurrency(value, 0); - } - - public static JournalLineRequestCurrency of(String value) { - return new JournalLineRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(JournalLineRequestCurrency.class); - } - - @java.lang.Override - public JournalLineRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequestTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequestTrackingCategoriesItem.java index 7cd57b490..58d2b57dd 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequestTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/JournalLineRequestTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer encoding; + private final Optional encoding; private final Optional fileName; @@ -36,7 +36,7 @@ public final class MultipartFormFieldRequest { private MultipartFormFieldRequest( String name, String data, - Optional encoding, + Optional encoding, Optional fileName, Optional contentType, Map additionalProperties) { @@ -73,7 +73,7 @@ public String getData() { * */ @JsonProperty("encoding") - public Optional getEncoding() { + public Optional getEncoding() { return encoding; } @@ -139,9 +139,9 @@ public interface DataStage { public interface _FinalStage { MultipartFormFieldRequest build(); - _FinalStage encoding(Optional encoding); + _FinalStage encoding(Optional encoding); - _FinalStage encoding(MultipartFormFieldRequestEncoding encoding); + _FinalStage encoding(EncodingEnum encoding); _FinalStage fileName(Optional fileName); @@ -162,7 +162,7 @@ public static final class Builder implements NameStage, DataStage, _FinalStage { private Optional fileName = Optional.empty(); - private Optional encoding = Optional.empty(); + private Optional encoding = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -245,14 +245,14 @@ public _FinalStage fileName(Optional fileName) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage encoding(MultipartFormFieldRequestEncoding encoding) { + public _FinalStage encoding(EncodingEnum encoding) { this.encoding = Optional.ofNullable(encoding); return this; } @java.lang.Override @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { + public _FinalStage encoding(Optional encoding) { this.encoding = encoding; return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/MultipartFormFieldRequestEncoding.java b/src/main/java/com/merge/api/resources/accounting/types/MultipartFormFieldRequestEncoding.java deleted file mode 100644 index ed2dbaa06..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/MultipartFormFieldRequestEncoding.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = MultipartFormFieldRequestEncoding.Deserializer.class) -public final class MultipartFormFieldRequestEncoding { - private final Object value; - - private final int type; - - private MultipartFormFieldRequestEncoding(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EncodingEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MultipartFormFieldRequestEncoding && equalTo((MultipartFormFieldRequestEncoding) other); - } - - private boolean equalTo(MultipartFormFieldRequestEncoding other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static MultipartFormFieldRequestEncoding of(EncodingEnum value) { - return new MultipartFormFieldRequestEncoding(value, 0); - } - - public static MultipartFormFieldRequestEncoding of(String value) { - return new MultipartFormFieldRequestEncoding(value, 1); - } - - public interface Visitor { - T visit(EncodingEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(MultipartFormFieldRequestEncoding.class); - } - - @java.lang.Override - public MultipartFormFieldRequestEncoding deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EncodingEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaginatedPaymentMethodList.java b/src/main/java/com/merge/api/resources/accounting/types/PaginatedPaymentMethodList.java new file mode 100644 index 000000000..45a8e0079 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/types/PaginatedPaymentMethodList.java @@ -0,0 +1,144 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaginatedPaymentMethodList.Builder.class) +public final class PaginatedPaymentMethodList { + private final Optional next; + + private final Optional previous; + + private final Optional> results; + + private final Map additionalProperties; + + private PaginatedPaymentMethodList( + Optional next, + Optional previous, + Optional> results, + Map additionalProperties) { + this.next = next; + this.previous = previous; + this.results = results; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("next") + public Optional getNext() { + return next; + } + + @JsonProperty("previous") + public Optional getPrevious() { + return previous; + } + + @JsonProperty("results") + public Optional> getResults() { + return results; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaginatedPaymentMethodList && equalTo((PaginatedPaymentMethodList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaginatedPaymentMethodList other) { + return next.equals(other.next) && previous.equals(other.previous) && results.equals(other.results); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.next, this.previous, this.results); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional next = Optional.empty(); + + private Optional previous = Optional.empty(); + + private Optional> results = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(PaginatedPaymentMethodList other) { + next(other.getNext()); + previous(other.getPrevious()); + results(other.getResults()); + return this; + } + + @JsonSetter(value = "next", nulls = Nulls.SKIP) + public Builder next(Optional next) { + this.next = next; + return this; + } + + public Builder next(String next) { + this.next = Optional.ofNullable(next); + return this; + } + + @JsonSetter(value = "previous", nulls = Nulls.SKIP) + public Builder previous(Optional previous) { + this.previous = previous; + return this; + } + + public Builder previous(String previous) { + this.previous = Optional.ofNullable(previous); + return this; + } + + @JsonSetter(value = "results", nulls = Nulls.SKIP) + public Builder results(Optional> results) { + this.results = results; + return this; + } + + public Builder results(List results) { + this.results = Optional.ofNullable(results); + return this; + } + + public PaginatedPaymentMethodList build() { + return new PaginatedPaymentMethodList(next, previous, results, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaginatedPaymentTermList.java b/src/main/java/com/merge/api/resources/accounting/types/PaginatedPaymentTermList.java new file mode 100644 index 000000000..977bd4193 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/types/PaginatedPaymentTermList.java @@ -0,0 +1,144 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaginatedPaymentTermList.Builder.class) +public final class PaginatedPaymentTermList { + private final Optional next; + + private final Optional previous; + + private final Optional> results; + + private final Map additionalProperties; + + private PaginatedPaymentTermList( + Optional next, + Optional previous, + Optional> results, + Map additionalProperties) { + this.next = next; + this.previous = previous; + this.results = results; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("next") + public Optional getNext() { + return next; + } + + @JsonProperty("previous") + public Optional getPrevious() { + return previous; + } + + @JsonProperty("results") + public Optional> getResults() { + return results; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaginatedPaymentTermList && equalTo((PaginatedPaymentTermList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaginatedPaymentTermList other) { + return next.equals(other.next) && previous.equals(other.previous) && results.equals(other.results); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.next, this.previous, this.results); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional next = Optional.empty(); + + private Optional previous = Optional.empty(); + + private Optional> results = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(PaginatedPaymentTermList other) { + next(other.getNext()); + previous(other.getPrevious()); + results(other.getResults()); + return this; + } + + @JsonSetter(value = "next", nulls = Nulls.SKIP) + public Builder next(Optional next) { + this.next = next; + return this; + } + + public Builder next(String next) { + this.next = Optional.ofNullable(next); + return this; + } + + @JsonSetter(value = "previous", nulls = Nulls.SKIP) + public Builder previous(Optional previous) { + this.previous = previous; + return this; + } + + public Builder previous(String previous) { + this.previous = Optional.ofNullable(previous); + return this; + } + + @JsonSetter(value = "results", nulls = Nulls.SKIP) + public Builder results(Optional> results) { + this.results = results; + return this; + } + + public Builder results(List results) { + this.results = Optional.ofNullable(results); + return this; + } + + public PaginatedPaymentTermList build() { + return new PaginatedPaymentTermList(next, previous, results, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequest.java b/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequest.java index c0995751f..c22482f26 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequest.java @@ -29,7 +29,9 @@ public final class PatchedPaymentRequest { private final Optional account; - private final Optional currency; + private final Optional paymentMethod; + + private final Optional currency; private final Optional exchangeRate; @@ -37,7 +39,7 @@ public final class PatchedPaymentRequest { private final Optional totalAmount; - private final Optional type; + private final Optional type; private final Optional>> trackingCategories; @@ -57,11 +59,12 @@ private PatchedPaymentRequest( Optional transactionDate, Optional contact, Optional account, - Optional currency, + Optional paymentMethod, + Optional currency, Optional exchangeRate, Optional company, Optional totalAmount, - Optional type, + Optional type, Optional>> trackingCategories, Optional accountingPeriod, Optional> appliedToLines, @@ -72,6 +75,7 @@ private PatchedPaymentRequest( this.transactionDate = transactionDate; this.contact = contact; this.account = account; + this.paymentMethod = paymentMethod; this.currency = currency; this.exchangeRate = exchangeRate; this.company = company; @@ -110,6 +114,14 @@ public Optional getAccount() { return account; } + /** + * @return The method which this payment was made by. + */ + @JsonProperty("payment_method") + public Optional getPaymentMethod() { + return paymentMethod; + } + /** * @return The payment's currency. *
      @@ -422,7 +434,7 @@ public Optional getAccount() { *
    */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -458,7 +470,7 @@ public Optional getTotalAmount() { * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -513,6 +525,7 @@ private boolean equalTo(PatchedPaymentRequest other) { return transactionDate.equals(other.transactionDate) && contact.equals(other.contact) && account.equals(other.account) + && paymentMethod.equals(other.paymentMethod) && currency.equals(other.currency) && exchangeRate.equals(other.exchangeRate) && company.equals(other.company) @@ -532,6 +545,7 @@ public int hashCode() { this.transactionDate, this.contact, this.account, + this.paymentMethod, this.currency, this.exchangeRate, this.company, @@ -562,7 +576,9 @@ public static final class Builder { private Optional account = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional paymentMethod = Optional.empty(); + + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -570,7 +586,7 @@ public static final class Builder { private Optional totalAmount = Optional.empty(); - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); private Optional>> trackingCategories = Optional.empty(); @@ -594,6 +610,7 @@ public Builder from(PatchedPaymentRequest other) { transactionDate(other.getTransactionDate()); contact(other.getContact()); account(other.getAccount()); + paymentMethod(other.getPaymentMethod()); currency(other.getCurrency()); exchangeRate(other.getExchangeRate()); company(other.getCompany()); @@ -641,13 +658,24 @@ public Builder account(PatchedPaymentRequestAccount account) { return this; } + @JsonSetter(value = "payment_method", nulls = Nulls.SKIP) + public Builder paymentMethod(Optional paymentMethod) { + this.paymentMethod = paymentMethod; + return this; + } + + public Builder paymentMethod(PatchedPaymentRequestPaymentMethod paymentMethod) { + this.paymentMethod = Optional.ofNullable(paymentMethod); + return this; + } + @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(PatchedPaymentRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @@ -686,12 +714,12 @@ public Builder totalAmount(Double totalAmount) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(PatchedPaymentRequestType type) { + public Builder type(PaymentTypeEnum type) { this.type = Optional.ofNullable(type); return this; } @@ -769,6 +797,7 @@ public PatchedPaymentRequest build() { transactionDate, contact, account, + paymentMethod, currency, exchangeRate, company, diff --git a/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestAccount.java b/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestAccount.java index c9c8e6eba..8cc29e4f3 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PatchedPaymentRequestCurrency && equalTo((PatchedPaymentRequestCurrency) other); - } - - private boolean equalTo(PatchedPaymentRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PatchedPaymentRequestCurrency of(TransactionCurrencyEnum value) { - return new PatchedPaymentRequestCurrency(value, 0); - } - - public static PatchedPaymentRequestCurrency of(String value) { - return new PatchedPaymentRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PatchedPaymentRequestCurrency.class); - } - - @java.lang.Override - public PatchedPaymentRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestPaymentMethod.java b/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestPaymentMethod.java new file mode 100644 index 000000000..49288dd1d --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestPaymentMethod.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.merge.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = PatchedPaymentRequestPaymentMethod.Deserializer.class) +public final class PatchedPaymentRequestPaymentMethod { + private final Object value; + + private final int type; + + private PatchedPaymentRequestPaymentMethod(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((PaymentMethod) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PatchedPaymentRequestPaymentMethod + && equalTo((PatchedPaymentRequestPaymentMethod) other); + } + + private boolean equalTo(PatchedPaymentRequestPaymentMethod other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static PatchedPaymentRequestPaymentMethod of(String value) { + return new PatchedPaymentRequestPaymentMethod(value, 0); + } + + public static PatchedPaymentRequestPaymentMethod of(PaymentMethod value) { + return new PatchedPaymentRequestPaymentMethod(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(PaymentMethod value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(PatchedPaymentRequestPaymentMethod.class); + } + + @java.lang.Override + public PatchedPaymentRequestPaymentMethod deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentMethod.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestTrackingCategoriesItem.java index af4214210..4da55be75 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PatchedPaymentRequestTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PaymentTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PatchedPaymentRequestType && equalTo((PatchedPaymentRequestType) other); - } - - private boolean equalTo(PatchedPaymentRequestType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PatchedPaymentRequestType of(PaymentTypeEnum value) { - return new PatchedPaymentRequestType(value, 0); - } - - public static PatchedPaymentRequestType of(String value) { - return new PatchedPaymentRequestType(value, 1); - } - - public interface Visitor { - T visit(PaymentTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PatchedPaymentRequestType.class); - } - - @java.lang.Override - public PatchedPaymentRequestType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/Payment.java b/src/main/java/com/merge/api/resources/accounting/types/Payment.java index 61a786e14..bc9dbaaa3 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/Payment.java +++ b/src/main/java/com/merge/api/resources/accounting/types/Payment.java @@ -37,7 +37,9 @@ public final class Payment { private final Optional account; - private final Optional currency; + private final Optional paymentMethod; + + private final Optional currency; private final Optional exchangeRate; @@ -45,7 +47,7 @@ public final class Payment { private final Optional totalAmount; - private final Optional type; + private final Optional type; private final Optional>> trackingCategories; @@ -73,11 +75,12 @@ private Payment( Optional transactionDate, Optional contact, Optional account, - Optional currency, + Optional paymentMethod, + Optional currency, Optional exchangeRate, Optional company, Optional totalAmount, - Optional type, + Optional type, Optional>> trackingCategories, Optional accountingPeriod, Optional> appliedToLines, @@ -94,6 +97,7 @@ private Payment( this.transactionDate = transactionDate; this.contact = contact; this.account = account; + this.paymentMethod = paymentMethod; this.currency = currency; this.exchangeRate = exchangeRate; this.company = company; @@ -163,6 +167,14 @@ public Optional getAccount() { return account; } + /** + * @return The method which this payment was made by. + */ + @JsonProperty("payment_method") + public Optional getPaymentMethod() { + return paymentMethod; + } + /** * @return The payment's currency. *
      @@ -475,7 +487,7 @@ public Optional getAccount() { *
    */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -511,7 +523,7 @@ public Optional getTotalAmount() { * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -586,6 +598,7 @@ private boolean equalTo(Payment other) { && transactionDate.equals(other.transactionDate) && contact.equals(other.contact) && account.equals(other.account) + && paymentMethod.equals(other.paymentMethod) && currency.equals(other.currency) && exchangeRate.equals(other.exchangeRate) && company.equals(other.company) @@ -611,6 +624,7 @@ public int hashCode() { this.transactionDate, this.contact, this.account, + this.paymentMethod, this.currency, this.exchangeRate, this.company, @@ -651,7 +665,9 @@ public static final class Builder { private Optional account = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional paymentMethod = Optional.empty(); + + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -659,7 +675,7 @@ public static final class Builder { private Optional totalAmount = Optional.empty(); - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); private Optional>> trackingCategories = Optional.empty(); @@ -690,6 +706,7 @@ public Builder from(Payment other) { transactionDate(other.getTransactionDate()); contact(other.getContact()); account(other.getAccount()); + paymentMethod(other.getPaymentMethod()); currency(other.getCurrency()); exchangeRate(other.getExchangeRate()); company(other.getCompany()); @@ -783,13 +800,24 @@ public Builder account(PaymentAccount account) { return this; } + @JsonSetter(value = "payment_method", nulls = Nulls.SKIP) + public Builder paymentMethod(Optional paymentMethod) { + this.paymentMethod = paymentMethod; + return this; + } + + public Builder paymentMethod(PaymentPaymentMethod paymentMethod) { + this.paymentMethod = Optional.ofNullable(paymentMethod); + return this; + } + @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(PaymentCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @@ -828,12 +856,12 @@ public Builder totalAmount(Double totalAmount) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(PaymentType type) { + public Builder type(PaymentTypeEnum type) { this.type = Optional.ofNullable(type); return this; } @@ -935,6 +963,7 @@ public Payment build() { transactionDate, contact, account, + paymentMethod, currency, exchangeRate, company, diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentAccount.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentAccount.java index 71fe91145..4d27be207 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PaymentAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PaymentAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentAccountingPeriod.java index d9a4efc76..62e460e0b 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public PaymentAccountingPeriod deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PaymentAccountingPeriod deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentAppliedToLinesItem.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentAppliedToLinesItem.java index 1103bfe3c..f177b3c16 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentAppliedToLinesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentAppliedToLinesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PaymentCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PaymentCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentContact.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentContact.java index 54eb87519..d102b4463 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentContact.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PaymentContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PaymentContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentCurrency.java deleted file mode 100644 index 7b27616f3..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PaymentCurrency.Deserializer.class) -public final class PaymentCurrency { - private final Object value; - - private final int type; - - private PaymentCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PaymentCurrency && equalTo((PaymentCurrency) other); - } - - private boolean equalTo(PaymentCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PaymentCurrency of(TransactionCurrencyEnum value) { - return new PaymentCurrency(value, 0); - } - - public static PaymentCurrency of(String value) { - return new PaymentCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PaymentCurrency.class); - } - - @java.lang.Override - public PaymentCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentMethod.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentMethod.java new file mode 100644 index 000000000..9871423db --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentMethod.java @@ -0,0 +1,457 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaymentMethod.Builder.class) +public final class PaymentMethod { + private final Optional id; + + private final Optional remoteId; + + private final Optional createdAt; + + private final Optional modifiedAt; + + private final MethodTypeEnum methodType; + + private final String name; + + private final Optional isActive; + + private final Optional remoteUpdatedAt; + + private final Optional> fieldMappings; + + private final Optional> remoteData; + + private final Map additionalProperties; + + private PaymentMethod( + Optional id, + Optional remoteId, + Optional createdAt, + Optional modifiedAt, + MethodTypeEnum methodType, + String name, + Optional isActive, + Optional remoteUpdatedAt, + Optional> fieldMappings, + Optional> remoteData, + Map additionalProperties) { + this.id = id; + this.remoteId = remoteId; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + this.methodType = methodType; + this.name = name; + this.isActive = isActive; + this.remoteUpdatedAt = remoteUpdatedAt; + this.fieldMappings = fieldMappings; + this.remoteData = remoteData; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The third-party API ID of the matching object. + */ + @JsonProperty("remote_id") + public Optional getRemoteId() { + return remoteId; + } + + /** + * @return The datetime that this object was created by Merge. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The datetime that this object was modified by Merge. + */ + @JsonProperty("modified_at") + public Optional getModifiedAt() { + return modifiedAt; + } + + /** + * @return The type of the payment method. + *
      + *
    • CREDIT_CARD - CREDIT_CARD
    • + *
    • DEBIT_CARD - DEBIT_CARD
    • + *
    • ACH - ACH
    • + *
    • CASH - CASH
    • + *
    • CHECK - CHECK
    • + *
    + */ + @JsonProperty("method_type") + public MethodTypeEnum getMethodType() { + return methodType; + } + + /** + * @return The payment method’s name + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return True if the payment method is active, False if not. + */ + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + + /** + * @return When the third party's payment method was updated. + */ + @JsonProperty("remote_updated_at") + public Optional getRemoteUpdatedAt() { + return remoteUpdatedAt; + } + + @JsonProperty("field_mappings") + public Optional> getFieldMappings() { + return fieldMappings; + } + + @JsonProperty("remote_data") + public Optional> getRemoteData() { + return remoteData; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaymentMethod && equalTo((PaymentMethod) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaymentMethod other) { + return id.equals(other.id) + && remoteId.equals(other.remoteId) + && createdAt.equals(other.createdAt) + && modifiedAt.equals(other.modifiedAt) + && methodType.equals(other.methodType) + && name.equals(other.name) + && isActive.equals(other.isActive) + && remoteUpdatedAt.equals(other.remoteUpdatedAt) + && fieldMappings.equals(other.fieldMappings) + && remoteData.equals(other.remoteData); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.remoteId, + this.createdAt, + this.modifiedAt, + this.methodType, + this.name, + this.isActive, + this.remoteUpdatedAt, + this.fieldMappings, + this.remoteData); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static MethodTypeStage builder() { + return new Builder(); + } + + public interface MethodTypeStage { + NameStage methodType(@NotNull MethodTypeEnum methodType); + + Builder from(PaymentMethod other); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + } + + public interface _FinalStage { + PaymentMethod build(); + + _FinalStage id(Optional id); + + _FinalStage id(String id); + + _FinalStage remoteId(Optional remoteId); + + _FinalStage remoteId(String remoteId); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(OffsetDateTime createdAt); + + _FinalStage modifiedAt(Optional modifiedAt); + + _FinalStage modifiedAt(OffsetDateTime modifiedAt); + + _FinalStage isActive(Optional isActive); + + _FinalStage isActive(Boolean isActive); + + _FinalStage remoteUpdatedAt(Optional remoteUpdatedAt); + + _FinalStage remoteUpdatedAt(OffsetDateTime remoteUpdatedAt); + + _FinalStage fieldMappings(Optional> fieldMappings); + + _FinalStage fieldMappings(Map fieldMappings); + + _FinalStage remoteData(Optional> remoteData); + + _FinalStage remoteData(List remoteData); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements MethodTypeStage, NameStage, _FinalStage { + private MethodTypeEnum methodType; + + private String name; + + private Optional> remoteData = Optional.empty(); + + private Optional> fieldMappings = Optional.empty(); + + private Optional remoteUpdatedAt = Optional.empty(); + + private Optional isActive = Optional.empty(); + + private Optional modifiedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional remoteId = Optional.empty(); + + private Optional id = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PaymentMethod other) { + id(other.getId()); + remoteId(other.getRemoteId()); + createdAt(other.getCreatedAt()); + modifiedAt(other.getModifiedAt()); + methodType(other.getMethodType()); + name(other.getName()); + isActive(other.getIsActive()); + remoteUpdatedAt(other.getRemoteUpdatedAt()); + fieldMappings(other.getFieldMappings()); + remoteData(other.getRemoteData()); + return this; + } + + /** + *

    The type of the payment method.

    + *
      + *
    • CREDIT_CARD - CREDIT_CARD
    • + *
    • DEBIT_CARD - DEBIT_CARD
    • + *
    • ACH - ACH
    • + *
    • CASH - CASH
    • + *
    • CHECK - CHECK
    • + *
    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("method_type") + public NameStage methodType(@NotNull MethodTypeEnum methodType) { + this.methodType = methodType; + return this; + } + + /** + *

    The payment method’s name

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = name; + return this; + } + + @java.lang.Override + public _FinalStage remoteData(List remoteData) { + this.remoteData = Optional.ofNullable(remoteData); + return this; + } + + @java.lang.Override + @JsonSetter(value = "remote_data", nulls = Nulls.SKIP) + public _FinalStage remoteData(Optional> remoteData) { + this.remoteData = remoteData; + return this; + } + + @java.lang.Override + public _FinalStage fieldMappings(Map fieldMappings) { + this.fieldMappings = Optional.ofNullable(fieldMappings); + return this; + } + + @java.lang.Override + @JsonSetter(value = "field_mappings", nulls = Nulls.SKIP) + public _FinalStage fieldMappings(Optional> fieldMappings) { + this.fieldMappings = fieldMappings; + return this; + } + + /** + *

    When the third party's payment method was updated.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage remoteUpdatedAt(OffsetDateTime remoteUpdatedAt) { + this.remoteUpdatedAt = Optional.ofNullable(remoteUpdatedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "remote_updated_at", nulls = Nulls.SKIP) + public _FinalStage remoteUpdatedAt(Optional remoteUpdatedAt) { + this.remoteUpdatedAt = remoteUpdatedAt; + return this; + } + + /** + *

    True if the payment method is active, False if not.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public _FinalStage isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + /** + *

    The datetime that this object was modified by Merge.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage modifiedAt(OffsetDateTime modifiedAt) { + this.modifiedAt = Optional.ofNullable(modifiedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "modified_at", nulls = Nulls.SKIP) + public _FinalStage modifiedAt(Optional modifiedAt) { + this.modifiedAt = modifiedAt; + return this; + } + + /** + *

    The datetime that this object was created by Merge.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdAt(OffsetDateTime createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

    The third-party API ID of the matching object.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage remoteId(String remoteId) { + this.remoteId = Optional.ofNullable(remoteId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "remote_id", nulls = Nulls.SKIP) + public _FinalStage remoteId(Optional remoteId) { + this.remoteId = remoteId; + return this; + } + + @java.lang.Override + public _FinalStage id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @java.lang.Override + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public _FinalStage id(Optional id) { + this.id = id; + return this; + } + + @java.lang.Override + public PaymentMethod build() { + return new PaymentMethod( + id, + remoteId, + createdAt, + modifiedAt, + methodType, + name, + isActive, + remoteUpdatedAt, + fieldMappings, + remoteData, + additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentPaymentMethod.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentPaymentMethod.java new file mode 100644 index 000000000..cbece113a --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentPaymentMethod.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.merge.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = PaymentPaymentMethod.Deserializer.class) +public final class PaymentPaymentMethod { + private final Object value; + + private final int type; + + private PaymentPaymentMethod(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((PaymentMethod) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaymentPaymentMethod && equalTo((PaymentPaymentMethod) other); + } + + private boolean equalTo(PaymentPaymentMethod other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static PaymentPaymentMethod of(String value) { + return new PaymentPaymentMethod(value, 0); + } + + public static PaymentPaymentMethod of(PaymentMethod value) { + return new PaymentPaymentMethod(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(PaymentMethod value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(PaymentPaymentMethod.class); + } + + @java.lang.Override + public PaymentPaymentMethod deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentMethod.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequest.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequest.java index 2862d6ffe..8712879e7 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequest.java @@ -29,7 +29,9 @@ public final class PaymentRequest { private final Optional account; - private final Optional currency; + private final Optional paymentMethod; + + private final Optional currency; private final Optional exchangeRate; @@ -37,7 +39,7 @@ public final class PaymentRequest { private final Optional totalAmount; - private final Optional type; + private final Optional type; private final Optional>> trackingCategories; @@ -57,11 +59,12 @@ private PaymentRequest( Optional transactionDate, Optional contact, Optional account, - Optional currency, + Optional paymentMethod, + Optional currency, Optional exchangeRate, Optional company, Optional totalAmount, - Optional type, + Optional type, Optional>> trackingCategories, Optional accountingPeriod, Optional> appliedToLines, @@ -72,6 +75,7 @@ private PaymentRequest( this.transactionDate = transactionDate; this.contact = contact; this.account = account; + this.paymentMethod = paymentMethod; this.currency = currency; this.exchangeRate = exchangeRate; this.company = company; @@ -110,6 +114,14 @@ public Optional getAccount() { return account; } + /** + * @return The method which this payment was made by. + */ + @JsonProperty("payment_method") + public Optional getPaymentMethod() { + return paymentMethod; + } + /** * @return The payment's currency. *
      @@ -422,7 +434,7 @@ public Optional getAccount() { *
    */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -458,7 +470,7 @@ public Optional getTotalAmount() { * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -513,6 +525,7 @@ private boolean equalTo(PaymentRequest other) { return transactionDate.equals(other.transactionDate) && contact.equals(other.contact) && account.equals(other.account) + && paymentMethod.equals(other.paymentMethod) && currency.equals(other.currency) && exchangeRate.equals(other.exchangeRate) && company.equals(other.company) @@ -532,6 +545,7 @@ public int hashCode() { this.transactionDate, this.contact, this.account, + this.paymentMethod, this.currency, this.exchangeRate, this.company, @@ -562,7 +576,9 @@ public static final class Builder { private Optional account = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional paymentMethod = Optional.empty(); + + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -570,7 +586,7 @@ public static final class Builder { private Optional totalAmount = Optional.empty(); - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); private Optional>> trackingCategories = Optional.empty(); @@ -593,6 +609,7 @@ public Builder from(PaymentRequest other) { transactionDate(other.getTransactionDate()); contact(other.getContact()); account(other.getAccount()); + paymentMethod(other.getPaymentMethod()); currency(other.getCurrency()); exchangeRate(other.getExchangeRate()); company(other.getCompany()); @@ -640,13 +657,24 @@ public Builder account(PaymentRequestAccount account) { return this; } + @JsonSetter(value = "payment_method", nulls = Nulls.SKIP) + public Builder paymentMethod(Optional paymentMethod) { + this.paymentMethod = paymentMethod; + return this; + } + + public Builder paymentMethod(PaymentRequestPaymentMethod paymentMethod) { + this.paymentMethod = Optional.ofNullable(paymentMethod); + return this; + } + @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(PaymentRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @@ -685,12 +713,12 @@ public Builder totalAmount(Double totalAmount) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(PaymentRequestType type) { + public Builder type(PaymentTypeEnum type) { this.type = Optional.ofNullable(type); return this; } @@ -767,6 +795,7 @@ public PaymentRequest build() { transactionDate, contact, account, + paymentMethod, currency, exchangeRate, company, diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestAccount.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestAccount.java index 1a1f4c89e..f8ee886a3 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PaymentRequestAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PaymentRequestAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestAccountingPeriod.java index 92a150b2d..9ab4a9bf4 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PaymentRequestCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PaymentRequestCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestContact.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestContact.java index b388d885a..1279bf72a 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestContact.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PaymentRequestContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PaymentRequestContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestCurrency.java deleted file mode 100644 index 285c0b69c..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PaymentRequestCurrency.Deserializer.class) -public final class PaymentRequestCurrency { - private final Object value; - - private final int type; - - private PaymentRequestCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PaymentRequestCurrency && equalTo((PaymentRequestCurrency) other); - } - - private boolean equalTo(PaymentRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PaymentRequestCurrency of(TransactionCurrencyEnum value) { - return new PaymentRequestCurrency(value, 0); - } - - public static PaymentRequestCurrency of(String value) { - return new PaymentRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PaymentRequestCurrency.class); - } - - @java.lang.Override - public PaymentRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestPaymentMethod.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestPaymentMethod.java new file mode 100644 index 000000000..3f52018ac --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestPaymentMethod.java @@ -0,0 +1,96 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.merge.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = PaymentRequestPaymentMethod.Deserializer.class) +public final class PaymentRequestPaymentMethod { + private final Object value; + + private final int type; + + private PaymentRequestPaymentMethod(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((PaymentMethod) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaymentRequestPaymentMethod && equalTo((PaymentRequestPaymentMethod) other); + } + + private boolean equalTo(PaymentRequestPaymentMethod other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static PaymentRequestPaymentMethod of(String value) { + return new PaymentRequestPaymentMethod(value, 0); + } + + public static PaymentRequestPaymentMethod of(PaymentMethod value) { + return new PaymentRequestPaymentMethod(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(PaymentMethod value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(PaymentRequestPaymentMethod.class); + } + + @java.lang.Override + public PaymentRequestPaymentMethod deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentMethod.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestTrackingCategoriesItem.java index 85d547f48..f5f93d774 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentRequestTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PaymentTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PaymentRequestType && equalTo((PaymentRequestType) other); - } - - private boolean equalTo(PaymentRequestType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PaymentRequestType of(PaymentTypeEnum value) { - return new PaymentRequestType(value, 0); - } - - public static PaymentRequestType of(String value) { - return new PaymentRequestType(value, 1); - } - - public interface Visitor { - T visit(PaymentTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PaymentRequestType.class); - } - - @java.lang.Override - public PaymentRequestType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentTerm.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentTerm.java new file mode 100644 index 000000000..d38fe96fe --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentTerm.java @@ -0,0 +1,527 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaymentTerm.Builder.class) +public final class PaymentTerm { + private final Optional id; + + private final Optional remoteId; + + private final Optional createdAt; + + private final Optional modifiedAt; + + private final String name; + + private final Optional isActive; + + private final Optional company; + + private final Optional daysUntilDue; + + private final Optional discountDays; + + private final Optional remoteLastModifiedAt; + + private final Optional> fieldMappings; + + private final Optional> remoteData; + + private final Map additionalProperties; + + private PaymentTerm( + Optional id, + Optional remoteId, + Optional createdAt, + Optional modifiedAt, + String name, + Optional isActive, + Optional company, + Optional daysUntilDue, + Optional discountDays, + Optional remoteLastModifiedAt, + Optional> fieldMappings, + Optional> remoteData, + Map additionalProperties) { + this.id = id; + this.remoteId = remoteId; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + this.name = name; + this.isActive = isActive; + this.company = company; + this.daysUntilDue = daysUntilDue; + this.discountDays = discountDays; + this.remoteLastModifiedAt = remoteLastModifiedAt; + this.fieldMappings = fieldMappings; + this.remoteData = remoteData; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + /** + * @return The third-party API ID of the matching object. + */ + @JsonProperty("remote_id") + public Optional getRemoteId() { + return remoteId; + } + + /** + * @return The datetime that this object was created by Merge. + */ + @JsonProperty("created_at") + public Optional getCreatedAt() { + return createdAt; + } + + /** + * @return The datetime that this object was modified by Merge. + */ + @JsonProperty("modified_at") + public Optional getModifiedAt() { + return modifiedAt; + } + + /** + * @return The name of the payment term. + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return True if the payment term is active, False if not. + */ + @JsonProperty("is_active") + public Optional getIsActive() { + return isActive; + } + + /** + * @return The subsidiary that the payment term belongs to. + */ + @JsonProperty("company") + public Optional getCompany() { + return company; + } + + /** + * @return The number of days after the invoice date that payment is due. + */ + @JsonProperty("days_until_due") + public Optional getDaysUntilDue() { + return daysUntilDue; + } + + /** + * @return The number of days the invoice must be paid before discounts expire. + */ + @JsonProperty("discount_days") + public Optional getDiscountDays() { + return discountDays; + } + + /** + * @return When the third party's payment term was modified. + */ + @JsonProperty("remote_last_modified_at") + public Optional getRemoteLastModifiedAt() { + return remoteLastModifiedAt; + } + + @JsonProperty("field_mappings") + public Optional> getFieldMappings() { + return fieldMappings; + } + + @JsonProperty("remote_data") + public Optional> getRemoteData() { + return remoteData; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaymentTerm && equalTo((PaymentTerm) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaymentTerm other) { + return id.equals(other.id) + && remoteId.equals(other.remoteId) + && createdAt.equals(other.createdAt) + && modifiedAt.equals(other.modifiedAt) + && name.equals(other.name) + && isActive.equals(other.isActive) + && company.equals(other.company) + && daysUntilDue.equals(other.daysUntilDue) + && discountDays.equals(other.discountDays) + && remoteLastModifiedAt.equals(other.remoteLastModifiedAt) + && fieldMappings.equals(other.fieldMappings) + && remoteData.equals(other.remoteData); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.remoteId, + this.createdAt, + this.modifiedAt, + this.name, + this.isActive, + this.company, + this.daysUntilDue, + this.discountDays, + this.remoteLastModifiedAt, + this.fieldMappings, + this.remoteData); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + _FinalStage name(@NotNull String name); + + Builder from(PaymentTerm other); + } + + public interface _FinalStage { + PaymentTerm build(); + + _FinalStage id(Optional id); + + _FinalStage id(String id); + + _FinalStage remoteId(Optional remoteId); + + _FinalStage remoteId(String remoteId); + + _FinalStage createdAt(Optional createdAt); + + _FinalStage createdAt(OffsetDateTime createdAt); + + _FinalStage modifiedAt(Optional modifiedAt); + + _FinalStage modifiedAt(OffsetDateTime modifiedAt); + + _FinalStage isActive(Optional isActive); + + _FinalStage isActive(Boolean isActive); + + _FinalStage company(Optional company); + + _FinalStage company(PaymentTermCompany company); + + _FinalStage daysUntilDue(Optional daysUntilDue); + + _FinalStage daysUntilDue(Integer daysUntilDue); + + _FinalStage discountDays(Optional discountDays); + + _FinalStage discountDays(Integer discountDays); + + _FinalStage remoteLastModifiedAt(Optional remoteLastModifiedAt); + + _FinalStage remoteLastModifiedAt(OffsetDateTime remoteLastModifiedAt); + + _FinalStage fieldMappings(Optional> fieldMappings); + + _FinalStage fieldMappings(Map fieldMappings); + + _FinalStage remoteData(Optional> remoteData); + + _FinalStage remoteData(List remoteData); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, _FinalStage { + private String name; + + private Optional> remoteData = Optional.empty(); + + private Optional> fieldMappings = Optional.empty(); + + private Optional remoteLastModifiedAt = Optional.empty(); + + private Optional discountDays = Optional.empty(); + + private Optional daysUntilDue = Optional.empty(); + + private Optional company = Optional.empty(); + + private Optional isActive = Optional.empty(); + + private Optional modifiedAt = Optional.empty(); + + private Optional createdAt = Optional.empty(); + + private Optional remoteId = Optional.empty(); + + private Optional id = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(PaymentTerm other) { + id(other.getId()); + remoteId(other.getRemoteId()); + createdAt(other.getCreatedAt()); + modifiedAt(other.getModifiedAt()); + name(other.getName()); + isActive(other.getIsActive()); + company(other.getCompany()); + daysUntilDue(other.getDaysUntilDue()); + discountDays(other.getDiscountDays()); + remoteLastModifiedAt(other.getRemoteLastModifiedAt()); + fieldMappings(other.getFieldMappings()); + remoteData(other.getRemoteData()); + return this; + } + + /** + *

    The name of the payment term.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("name") + public _FinalStage name(@NotNull String name) { + this.name = name; + return this; + } + + @java.lang.Override + public _FinalStage remoteData(List remoteData) { + this.remoteData = Optional.ofNullable(remoteData); + return this; + } + + @java.lang.Override + @JsonSetter(value = "remote_data", nulls = Nulls.SKIP) + public _FinalStage remoteData(Optional> remoteData) { + this.remoteData = remoteData; + return this; + } + + @java.lang.Override + public _FinalStage fieldMappings(Map fieldMappings) { + this.fieldMappings = Optional.ofNullable(fieldMappings); + return this; + } + + @java.lang.Override + @JsonSetter(value = "field_mappings", nulls = Nulls.SKIP) + public _FinalStage fieldMappings(Optional> fieldMappings) { + this.fieldMappings = fieldMappings; + return this; + } + + /** + *

    When the third party's payment term was modified.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage remoteLastModifiedAt(OffsetDateTime remoteLastModifiedAt) { + this.remoteLastModifiedAt = Optional.ofNullable(remoteLastModifiedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "remote_last_modified_at", nulls = Nulls.SKIP) + public _FinalStage remoteLastModifiedAt(Optional remoteLastModifiedAt) { + this.remoteLastModifiedAt = remoteLastModifiedAt; + return this; + } + + /** + *

    The number of days the invoice must be paid before discounts expire.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage discountDays(Integer discountDays) { + this.discountDays = Optional.ofNullable(discountDays); + return this; + } + + @java.lang.Override + @JsonSetter(value = "discount_days", nulls = Nulls.SKIP) + public _FinalStage discountDays(Optional discountDays) { + this.discountDays = discountDays; + return this; + } + + /** + *

    The number of days after the invoice date that payment is due.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage daysUntilDue(Integer daysUntilDue) { + this.daysUntilDue = Optional.ofNullable(daysUntilDue); + return this; + } + + @java.lang.Override + @JsonSetter(value = "days_until_due", nulls = Nulls.SKIP) + public _FinalStage daysUntilDue(Optional daysUntilDue) { + this.daysUntilDue = daysUntilDue; + return this; + } + + /** + *

    The subsidiary that the payment term belongs to.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage company(PaymentTermCompany company) { + this.company = Optional.ofNullable(company); + return this; + } + + @java.lang.Override + @JsonSetter(value = "company", nulls = Nulls.SKIP) + public _FinalStage company(Optional company) { + this.company = company; + return this; + } + + /** + *

    True if the payment term is active, False if not.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage isActive(Boolean isActive) { + this.isActive = Optional.ofNullable(isActive); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_active", nulls = Nulls.SKIP) + public _FinalStage isActive(Optional isActive) { + this.isActive = isActive; + return this; + } + + /** + *

    The datetime that this object was modified by Merge.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage modifiedAt(OffsetDateTime modifiedAt) { + this.modifiedAt = Optional.ofNullable(modifiedAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "modified_at", nulls = Nulls.SKIP) + public _FinalStage modifiedAt(Optional modifiedAt) { + this.modifiedAt = modifiedAt; + return this; + } + + /** + *

    The datetime that this object was created by Merge.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage createdAt(OffsetDateTime createdAt) { + this.createdAt = Optional.ofNullable(createdAt); + return this; + } + + @java.lang.Override + @JsonSetter(value = "created_at", nulls = Nulls.SKIP) + public _FinalStage createdAt(Optional createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + *

    The third-party API ID of the matching object.

    + * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage remoteId(String remoteId) { + this.remoteId = Optional.ofNullable(remoteId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "remote_id", nulls = Nulls.SKIP) + public _FinalStage remoteId(Optional remoteId) { + this.remoteId = remoteId; + return this; + } + + @java.lang.Override + public _FinalStage id(String id) { + this.id = Optional.ofNullable(id); + return this; + } + + @java.lang.Override + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public _FinalStage id(Optional id) { + this.id = id; + return this; + } + + @java.lang.Override + public PaymentTerm build() { + return new PaymentTerm( + id, + remoteId, + createdAt, + modifiedAt, + name, + isActive, + company, + daysUntilDue, + discountDays, + remoteLastModifiedAt, + fieldMappings, + remoteData, + additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentTermCompany.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentTermCompany.java new file mode 100644 index 000000000..17e0b87f0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentTermCompany.java @@ -0,0 +1,95 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.merge.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = PaymentTermCompany.Deserializer.class) +public final class PaymentTermCompany { + private final Object value; + + private final int type; + + private PaymentTermCompany(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((CompanyInfo) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaymentTermCompany && equalTo((PaymentTermCompany) other); + } + + private boolean equalTo(PaymentTermCompany other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static PaymentTermCompany of(String value) { + return new PaymentTermCompany(value, 0); + } + + public static PaymentTermCompany of(CompanyInfo value) { + return new PaymentTermCompany(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(CompanyInfo value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(PaymentTermCompany.class); + } + + @java.lang.Override + public PaymentTermCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, CompanyInfo.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PaymentTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/PaymentTrackingCategoriesItem.java index 11740c949..ab5f6bb42 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PaymentTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PaymentTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PaymentTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PaymentType && equalTo((PaymentType) other); - } - - private boolean equalTo(PaymentType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PaymentType of(PaymentTypeEnum value) { - return new PaymentType(value, 0); - } - - public static PaymentType of(String value) { - return new PaymentType(value, 1); - } - - public interface Visitor { - T visit(PaymentTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PaymentType.class); - } - - @java.lang.Override - public PaymentType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrder.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrder.java index bbdf7c3f3..ba6e73b38 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrder.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrder.java @@ -31,7 +31,7 @@ public final class PurchaseOrder { private final Optional modifiedAt; - private final Optional status; + private final Optional status; private final Optional issueDate; @@ -51,10 +51,12 @@ public final class PurchaseOrder { private final Optional totalAmount; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; + private final Optional paymentTerm; + private final Optional> lineItems; private final Optional inclusiveOfTax; @@ -82,7 +84,7 @@ private PurchaseOrder( Optional remoteId, Optional createdAt, Optional modifiedAt, - Optional status, + Optional status, Optional issueDate, Optional purchaseOrderNumber, Optional deliveryDate, @@ -92,8 +94,9 @@ private PurchaseOrder( Optional memo, Optional company, Optional totalAmount, - Optional currency, + Optional currency, Optional exchangeRate, + Optional paymentTerm, Optional> lineItems, Optional inclusiveOfTax, Optional>> trackingCategories, @@ -121,6 +124,7 @@ private PurchaseOrder( this.totalAmount = totalAmount; this.currency = currency; this.exchangeRate = exchangeRate; + this.paymentTerm = paymentTerm; this.lineItems = lineItems; this.inclusiveOfTax = inclusiveOfTax; this.trackingCategories = trackingCategories; @@ -174,7 +178,7 @@ public Optional getModifiedAt() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -562,7 +566,7 @@ public Optional getTotalAmount() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -574,6 +578,14 @@ public Optional getExchangeRate() { return exchangeRate; } + /** + * @return The payment term that applies to this transaction. + */ + @JsonProperty("payment_term") + public Optional getPaymentTerm() { + return paymentTerm; + } + @JsonProperty("line_items") public Optional> getLineItems() { return lineItems; @@ -667,6 +679,7 @@ private boolean equalTo(PurchaseOrder other) { && totalAmount.equals(other.totalAmount) && currency.equals(other.currency) && exchangeRate.equals(other.exchangeRate) + && paymentTerm.equals(other.paymentTerm) && lineItems.equals(other.lineItems) && inclusiveOfTax.equals(other.inclusiveOfTax) && trackingCategories.equals(other.trackingCategories) @@ -698,6 +711,7 @@ public int hashCode() { this.totalAmount, this.currency, this.exchangeRate, + this.paymentTerm, this.lineItems, this.inclusiveOfTax, this.trackingCategories, @@ -729,7 +743,7 @@ public static final class Builder { private Optional modifiedAt = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional issueDate = Optional.empty(); @@ -749,10 +763,12 @@ public static final class Builder { private Optional totalAmount = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); + private Optional paymentTerm = Optional.empty(); + private Optional> lineItems = Optional.empty(); private Optional inclusiveOfTax = Optional.empty(); @@ -795,6 +811,7 @@ public Builder from(PurchaseOrder other) { totalAmount(other.getTotalAmount()); currency(other.getCurrency()); exchangeRate(other.getExchangeRate()); + paymentTerm(other.getPaymentTerm()); lineItems(other.getLineItems()); inclusiveOfTax(other.getInclusiveOfTax()); trackingCategories(other.getTrackingCategories()); @@ -853,12 +870,12 @@ public Builder modifiedAt(OffsetDateTime modifiedAt) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(PurchaseOrderStatus status) { + public Builder status(PurchaseOrderStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -963,12 +980,12 @@ public Builder totalAmount(Double totalAmount) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(PurchaseOrderCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @@ -984,6 +1001,17 @@ public Builder exchangeRate(String exchangeRate) { return this; } + @JsonSetter(value = "payment_term", nulls = Nulls.SKIP) + public Builder paymentTerm(Optional paymentTerm) { + this.paymentTerm = paymentTerm; + return this; + } + + public Builder paymentTerm(PurchaseOrderPaymentTerm paymentTerm) { + this.paymentTerm = Optional.ofNullable(paymentTerm); + return this; + } + @JsonSetter(value = "line_items", nulls = Nulls.SKIP) public Builder lineItems(Optional> lineItems) { this.lineItems = lineItems; @@ -1113,6 +1141,7 @@ public PurchaseOrder build() { totalAmount, currency, exchangeRate, + paymentTerm, lineItems, inclusiveOfTax, trackingCategories, diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderAccountingPeriod.java index 1ec1aa022..7c9217ce6 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PurchaseOrderCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PurchaseOrderCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderCurrency.java deleted file mode 100644 index 86e23c616..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PurchaseOrderCurrency.Deserializer.class) -public final class PurchaseOrderCurrency { - private final Object value; - - private final int type; - - private PurchaseOrderCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PurchaseOrderCurrency && equalTo((PurchaseOrderCurrency) other); - } - - private boolean equalTo(PurchaseOrderCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PurchaseOrderCurrency of(TransactionCurrencyEnum value) { - return new PurchaseOrderCurrency(value, 0); - } - - public static PurchaseOrderCurrency of(String value) { - return new PurchaseOrderCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PurchaseOrderCurrency.class); - } - - @java.lang.Override - public PurchaseOrderCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderDeliveryAddress.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderDeliveryAddress.java index 1cc2006fe..965c4d0ff 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderDeliveryAddress.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderDeliveryAddress.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer totalLineAmount; - private final Optional currency; + private final Optional currency; private final Optional taxRate; @@ -76,7 +76,7 @@ private PurchaseOrderLineItem( Optional>> trackingCategories, Optional taxAmount, Optional totalLineAmount, - Optional currency, + Optional currency, Optional taxRate, Optional exchangeRate, Optional company, @@ -515,7 +515,7 @@ public Optional getTotalLineAmount() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -650,7 +650,7 @@ public static final class Builder { private Optional totalLineAmount = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional taxRate = Optional.empty(); @@ -834,12 +834,12 @@ public Builder totalLineAmount(String totalLineAmount) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(PurchaseOrderLineItemCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemCurrency.java deleted file mode 100644 index d106d7b61..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PurchaseOrderLineItemCurrency.Deserializer.class) -public final class PurchaseOrderLineItemCurrency { - private final Object value; - - private final int type; - - private PurchaseOrderLineItemCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PurchaseOrderLineItemCurrency && equalTo((PurchaseOrderLineItemCurrency) other); - } - - private boolean equalTo(PurchaseOrderLineItemCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PurchaseOrderLineItemCurrency of(TransactionCurrencyEnum value) { - return new PurchaseOrderLineItemCurrency(value, 0); - } - - public static PurchaseOrderLineItemCurrency of(String value) { - return new PurchaseOrderLineItemCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PurchaseOrderLineItemCurrency.class); - } - - @java.lang.Override - public PurchaseOrderLineItemCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemItem.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemItem.java index 0b8566609..88cb8db75 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer totalLineAmount; - private final Optional currency; + private final Optional currency; private final Optional taxRate; @@ -69,7 +69,7 @@ private PurchaseOrderLineItemRequest( Optional>> trackingCategories, Optional taxAmount, Optional totalLineAmount, - Optional currency, + Optional currency, Optional taxRate, Optional exchangeRate, Optional company, @@ -486,7 +486,7 @@ public Optional getTotalLineAmount() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -613,7 +613,7 @@ public static final class Builder { private Optional totalLineAmount = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional taxRate = Optional.empty(); @@ -764,12 +764,12 @@ public Builder totalLineAmount(String totalLineAmount) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(PurchaseOrderLineItemRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemRequestCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemRequestCurrency.java deleted file mode 100644 index 349fd39cb..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemRequestCurrency.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PurchaseOrderLineItemRequestCurrency.Deserializer.class) -public final class PurchaseOrderLineItemRequestCurrency { - private final Object value; - - private final int type; - - private PurchaseOrderLineItemRequestCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PurchaseOrderLineItemRequestCurrency - && equalTo((PurchaseOrderLineItemRequestCurrency) other); - } - - private boolean equalTo(PurchaseOrderLineItemRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PurchaseOrderLineItemRequestCurrency of(TransactionCurrencyEnum value) { - return new PurchaseOrderLineItemRequestCurrency(value, 0); - } - - public static PurchaseOrderLineItemRequestCurrency of(String value) { - return new PurchaseOrderLineItemRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PurchaseOrderLineItemRequestCurrency.class); - } - - @java.lang.Override - public PurchaseOrderLineItemRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemRequestItem.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemRequestItem.java index 099222308..89b920b22 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemRequestItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderLineItemRequestItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((PaymentTerm) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PurchaseOrderPaymentTerm && equalTo((PurchaseOrderPaymentTerm) other); + } + + private boolean equalTo(PurchaseOrderPaymentTerm other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static PurchaseOrderPaymentTerm of(String value) { + return new PurchaseOrderPaymentTerm(value, 0); + } + + public static PurchaseOrderPaymentTerm of(PaymentTerm value) { + return new PurchaseOrderPaymentTerm(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(PaymentTerm value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(PurchaseOrderPaymentTerm.class); + } + + @java.lang.Override + public PurchaseOrderPaymentTerm deserialize(JsonParser p, DeserializationContext context) throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentTerm.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequest.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequest.java index db2131866..d7b739c0b 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequest.java @@ -23,7 +23,7 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = PurchaseOrderRequest.Builder.class) public final class PurchaseOrderRequest { - private final Optional status; + private final Optional status; private final Optional issueDate; @@ -41,7 +41,9 @@ public final class PurchaseOrderRequest { private final Optional totalAmount; - private final Optional currency; + private final Optional paymentTerm; + + private final Optional currency; private final Optional inclusiveOfTax; @@ -60,7 +62,7 @@ public final class PurchaseOrderRequest { private final Map additionalProperties; private PurchaseOrderRequest( - Optional status, + Optional status, Optional issueDate, Optional deliveryDate, Optional deliveryAddress, @@ -69,7 +71,8 @@ private PurchaseOrderRequest( Optional memo, Optional company, Optional totalAmount, - Optional currency, + Optional paymentTerm, + Optional currency, Optional inclusiveOfTax, Optional exchangeRate, Optional>> trackingCategories, @@ -87,6 +90,7 @@ private PurchaseOrderRequest( this.memo = memo; this.company = company; this.totalAmount = totalAmount; + this.paymentTerm = paymentTerm; this.currency = currency; this.inclusiveOfTax = inclusiveOfTax; this.exchangeRate = exchangeRate; @@ -109,7 +113,7 @@ private PurchaseOrderRequest( * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -177,6 +181,14 @@ public Optional getTotalAmount() { return totalAmount; } + /** + * @return The payment term that applies to this transaction. + */ + @JsonProperty("payment_term") + public Optional getPaymentTerm() { + return paymentTerm; + } + /** * @return The purchase order's currency. *
      @@ -489,7 +501,7 @@ public Optional getTotalAmount() { *
    */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -555,6 +567,7 @@ private boolean equalTo(PurchaseOrderRequest other) { && memo.equals(other.memo) && company.equals(other.company) && totalAmount.equals(other.totalAmount) + && paymentTerm.equals(other.paymentTerm) && currency.equals(other.currency) && inclusiveOfTax.equals(other.inclusiveOfTax) && exchangeRate.equals(other.exchangeRate) @@ -577,6 +590,7 @@ public int hashCode() { this.memo, this.company, this.totalAmount, + this.paymentTerm, this.currency, this.inclusiveOfTax, this.exchangeRate, @@ -598,7 +612,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional issueDate = Optional.empty(); @@ -616,7 +630,9 @@ public static final class Builder { private Optional totalAmount = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional paymentTerm = Optional.empty(); + + private Optional currency = Optional.empty(); private Optional inclusiveOfTax = Optional.empty(); @@ -648,6 +664,7 @@ public Builder from(PurchaseOrderRequest other) { memo(other.getMemo()); company(other.getCompany()); totalAmount(other.getTotalAmount()); + paymentTerm(other.getPaymentTerm()); currency(other.getCurrency()); inclusiveOfTax(other.getInclusiveOfTax()); exchangeRate(other.getExchangeRate()); @@ -660,12 +677,12 @@ public Builder from(PurchaseOrderRequest other) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(PurchaseOrderRequestStatus status) { + public Builder status(PurchaseOrderStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -758,13 +775,24 @@ public Builder totalAmount(Double totalAmount) { return this; } + @JsonSetter(value = "payment_term", nulls = Nulls.SKIP) + public Builder paymentTerm(Optional paymentTerm) { + this.paymentTerm = paymentTerm; + return this; + } + + public Builder paymentTerm(PurchaseOrderRequestPaymentTerm paymentTerm) { + this.paymentTerm = Optional.ofNullable(paymentTerm); + return this; + } + @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(PurchaseOrderRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } @@ -859,6 +887,7 @@ public PurchaseOrderRequest build() { memo, company, totalAmount, + paymentTerm, currency, inclusiveOfTax, exchangeRate, diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestCompany.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestCompany.java index 46a6bfa66..89fcf53ce 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PurchaseOrderRequestCurrency && equalTo((PurchaseOrderRequestCurrency) other); - } - - private boolean equalTo(PurchaseOrderRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PurchaseOrderRequestCurrency of(TransactionCurrencyEnum value) { - return new PurchaseOrderRequestCurrency(value, 0); - } - - public static PurchaseOrderRequestCurrency of(String value) { - return new PurchaseOrderRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PurchaseOrderRequestCurrency.class); - } - - @java.lang.Override - public PurchaseOrderRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestDeliveryAddress.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestDeliveryAddress.java index 2ed240911..4e1cd2d10 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestDeliveryAddress.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestDeliveryAddress.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((PaymentTerm) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PurchaseOrderRequestPaymentTerm && equalTo((PurchaseOrderRequestPaymentTerm) other); + } + + private boolean equalTo(PurchaseOrderRequestPaymentTerm other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static PurchaseOrderRequestPaymentTerm of(String value) { + return new PurchaseOrderRequestPaymentTerm(value, 0); + } + + public static PurchaseOrderRequestPaymentTerm of(PaymentTerm value) { + return new PurchaseOrderRequestPaymentTerm(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(PaymentTerm value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(PurchaseOrderRequestPaymentTerm.class); + } + + @java.lang.Override + public PurchaseOrderRequestPaymentTerm deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentTerm.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestStatus.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestStatus.java deleted file mode 100644 index 30c494932..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PurchaseOrderRequestStatus.Deserializer.class) -public final class PurchaseOrderRequestStatus { - private final Object value; - - private final int type; - - private PurchaseOrderRequestStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PurchaseOrderStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PurchaseOrderRequestStatus && equalTo((PurchaseOrderRequestStatus) other); - } - - private boolean equalTo(PurchaseOrderRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PurchaseOrderRequestStatus of(PurchaseOrderStatusEnum value) { - return new PurchaseOrderRequestStatus(value, 0); - } - - public static PurchaseOrderRequestStatus of(String value) { - return new PurchaseOrderRequestStatus(value, 1); - } - - public interface Visitor { - T visit(PurchaseOrderStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PurchaseOrderRequestStatus.class); - } - - @java.lang.Override - public PurchaseOrderRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PurchaseOrderStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestTrackingCategoriesItem.java index bf130b60e..8575a2ad7 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderRequestTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PurchaseOrderStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PurchaseOrderStatus && equalTo((PurchaseOrderStatus) other); - } - - private boolean equalTo(PurchaseOrderStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PurchaseOrderStatus of(PurchaseOrderStatusEnum value) { - return new PurchaseOrderStatus(value, 0); - } - - public static PurchaseOrderStatus of(String value) { - return new PurchaseOrderStatus(value, 1); - } - - public interface Visitor { - T visit(PurchaseOrderStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PurchaseOrderStatus.class); - } - - @java.lang.Override - public PurchaseOrderStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PurchaseOrderStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderTrackingCategoriesItem.java index 02221f98c..bfdfdfc1c 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/PurchaseOrderTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PurchaseOrderVendor deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PurchaseOrderVendor deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/RemoteField.java b/src/main/java/com/merge/api/resources/accounting/types/RemoteField.java index eb532fd60..f14eaf546 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/RemoteField.java +++ b/src/main/java/com/merge/api/resources/accounting/types/RemoteField.java @@ -22,15 +22,15 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = RemoteField.Builder.class) public final class RemoteField { - private final RemoteFieldClass remoteFieldClass; + private final RemoteFieldRemoteFieldClass remoteFieldClass; - private final Optional> value; + private final Optional value; private final Map additionalProperties; private RemoteField( - RemoteFieldClass remoteFieldClass, - Optional> value, + RemoteFieldRemoteFieldClass remoteFieldClass, + Optional value, Map additionalProperties) { this.remoteFieldClass = remoteFieldClass; this.value = value; @@ -38,12 +38,12 @@ private RemoteField( } @JsonProperty("remote_field_class") - public RemoteFieldClass getRemoteFieldClass() { + public RemoteFieldRemoteFieldClass getRemoteFieldClass() { return remoteFieldClass; } @JsonProperty("value") - public Optional> getValue() { + public Optional getValue() { return value; } @@ -77,7 +77,7 @@ public static RemoteFieldClassStage builder() { } public interface RemoteFieldClassStage { - _FinalStage remoteFieldClass(@NotNull RemoteFieldClass remoteFieldClass); + _FinalStage remoteFieldClass(@NotNull RemoteFieldRemoteFieldClass remoteFieldClass); Builder from(RemoteField other); } @@ -85,16 +85,16 @@ public interface RemoteFieldClassStage { public interface _FinalStage { RemoteField build(); - _FinalStage value(Optional> value); + _FinalStage value(Optional value); - _FinalStage value(Map value); + _FinalStage value(JsonNode value); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements RemoteFieldClassStage, _FinalStage { - private RemoteFieldClass remoteFieldClass; + private RemoteFieldRemoteFieldClass remoteFieldClass; - private Optional> value = Optional.empty(); + private Optional value = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -110,20 +110,20 @@ public Builder from(RemoteField other) { @java.lang.Override @JsonSetter("remote_field_class") - public _FinalStage remoteFieldClass(@NotNull RemoteFieldClass remoteFieldClass) { + public _FinalStage remoteFieldClass(@NotNull RemoteFieldRemoteFieldClass remoteFieldClass) { this.remoteFieldClass = remoteFieldClass; return this; } @java.lang.Override - public _FinalStage value(Map value) { + public _FinalStage value(JsonNode value) { this.value = Optional.ofNullable(value); return this; } @java.lang.Override @JsonSetter(value = "value", nulls = Nulls.SKIP) - public _FinalStage value(Optional> value) { + public _FinalStage value(Optional value) { this.value = value; return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldApiCoverage.java b/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldApiCoverage.java index f00aa6838..f7f68b1d3 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldApiCoverage.java +++ b/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldApiCoverage.java @@ -28,6 +28,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((int) this.value); @@ -77,7 +78,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); if (value instanceof Integer) { return of((Integer) value); diff --git a/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldApiResponse.java b/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldApiResponse.java index 9cab949ae..45cb989b9 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldApiResponse.java +++ b/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldApiResponse.java @@ -65,6 +65,10 @@ public final class RemoteFieldApiResponse { private final Optional> employee; + private final Optional> paymentMethod; + + private final Optional> paymentTerm; + private final Map additionalProperties; private RemoteFieldApiResponse( @@ -90,6 +94,8 @@ private RemoteFieldApiResponse( Optional> generalLedgerTransaction, Optional> bankFeedAccount, Optional> employee, + Optional> paymentMethod, + Optional> paymentTerm, Map additionalProperties) { this.account = account; this.accountingAttachment = accountingAttachment; @@ -113,6 +119,8 @@ private RemoteFieldApiResponse( this.generalLedgerTransaction = generalLedgerTransaction; this.bankFeedAccount = bankFeedAccount; this.employee = employee; + this.paymentMethod = paymentMethod; + this.paymentTerm = paymentTerm; this.additionalProperties = additionalProperties; } @@ -226,6 +234,16 @@ public Optional> getEmployee() { return employee; } + @JsonProperty("PaymentMethod") + public Optional> getPaymentMethod() { + return paymentMethod; + } + + @JsonProperty("PaymentTerm") + public Optional> getPaymentTerm() { + return paymentTerm; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -259,7 +277,9 @@ private boolean equalTo(RemoteFieldApiResponse other) { && accountingPeriod.equals(other.accountingPeriod) && generalLedgerTransaction.equals(other.generalLedgerTransaction) && bankFeedAccount.equals(other.bankFeedAccount) - && employee.equals(other.employee); + && employee.equals(other.employee) + && paymentMethod.equals(other.paymentMethod) + && paymentTerm.equals(other.paymentTerm); } @java.lang.Override @@ -286,7 +306,9 @@ public int hashCode() { this.accountingPeriod, this.generalLedgerTransaction, this.bankFeedAccount, - this.employee); + this.employee, + this.paymentMethod, + this.paymentTerm); } @java.lang.Override @@ -344,6 +366,10 @@ public static final class Builder { private Optional> employee = Optional.empty(); + private Optional> paymentMethod = Optional.empty(); + + private Optional> paymentTerm = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -372,6 +398,8 @@ public Builder from(RemoteFieldApiResponse other) { generalLedgerTransaction(other.getGeneralLedgerTransaction()); bankFeedAccount(other.getBankFeedAccount()); employee(other.getEmployee()); + paymentMethod(other.getPaymentMethod()); + paymentTerm(other.getPaymentTerm()); return this; } @@ -617,6 +645,28 @@ public Builder employee(List employee) { return this; } + @JsonSetter(value = "PaymentMethod", nulls = Nulls.SKIP) + public Builder paymentMethod(Optional> paymentMethod) { + this.paymentMethod = paymentMethod; + return this; + } + + public Builder paymentMethod(List paymentMethod) { + this.paymentMethod = Optional.ofNullable(paymentMethod); + return this; + } + + @JsonSetter(value = "PaymentTerm", nulls = Nulls.SKIP) + public Builder paymentTerm(Optional> paymentTerm) { + this.paymentTerm = paymentTerm; + return this; + } + + public Builder paymentTerm(List paymentTerm) { + this.paymentTerm = Optional.ofNullable(paymentTerm); + return this; + } + public RemoteFieldApiResponse build() { return new RemoteFieldApiResponse( account, @@ -641,6 +691,8 @@ public RemoteFieldApiResponse build() { generalLedgerTransaction, bankFeedAccount, employee, + paymentMethod, + paymentTerm, additionalProperties); } } diff --git a/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldRemoteFieldClass.java b/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldRemoteFieldClass.java new file mode 100644 index 000000000..0079675d5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldRemoteFieldClass.java @@ -0,0 +1,96 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.merge.api.core.ObjectMappers; +import java.io.IOException; +import java.util.Objects; + +@JsonDeserialize(using = RemoteFieldRemoteFieldClass.Deserializer.class) +public final class RemoteFieldRemoteFieldClass { + private final Object value; + + private final int type; + + private RemoteFieldRemoteFieldClass(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((String) this.value); + } else if (this.type == 1) { + return visitor.visit((RemoteFieldClass) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof RemoteFieldRemoteFieldClass && equalTo((RemoteFieldRemoteFieldClass) other); + } + + private boolean equalTo(RemoteFieldRemoteFieldClass other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static RemoteFieldRemoteFieldClass of(String value) { + return new RemoteFieldRemoteFieldClass(value, 0); + } + + public static RemoteFieldRemoteFieldClass of(RemoteFieldClass value) { + return new RemoteFieldRemoteFieldClass(value, 1); + } + + public interface Visitor { + T visit(String value); + + T visit(RemoteFieldClass value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(RemoteFieldRemoteFieldClass.class); + } + + @java.lang.Override + public RemoteFieldRemoteFieldClass deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (IllegalArgumentException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, RemoteFieldClass.class)); + } catch (IllegalArgumentException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldRequestRemoteFieldClass.java b/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldRequestRemoteFieldClass.java index b3ed43207..5c02db0bc 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldRequestRemoteFieldClass.java +++ b/src/main/java/com/merge/api/resources/accounting/types/RemoteFieldRequestRemoteFieldClass.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer nextSyncStart; - private final SyncStatusStatusEnum status; + private final Optional lastSyncResult; + + private final Optional lastSyncFinished; + + private final StatusFd5Enum status; private final boolean isInitialSync; @@ -43,7 +47,9 @@ private SyncStatus( String modelId, Optional lastSyncStart, Optional nextSyncStart, - SyncStatusStatusEnum status, + Optional lastSyncResult, + Optional lastSyncFinished, + StatusFd5Enum status, boolean isInitialSync, Optional selectiveSyncConfigurationsUsage, Map additionalProperties) { @@ -51,6 +57,8 @@ private SyncStatus( this.modelId = modelId; this.lastSyncStart = lastSyncStart; this.nextSyncStart = nextSyncStart; + this.lastSyncResult = lastSyncResult; + this.lastSyncFinished = lastSyncFinished; this.status = status; this.isInitialSync = isInitialSync; this.selectiveSyncConfigurationsUsage = selectiveSyncConfigurationsUsage; @@ -77,8 +85,18 @@ public Optional getNextSyncStart() { return nextSyncStart; } + @JsonProperty("last_sync_result") + public Optional getLastSyncResult() { + return lastSyncResult; + } + + @JsonProperty("last_sync_finished") + public Optional getLastSyncFinished() { + return lastSyncFinished; + } + @JsonProperty("status") - public SyncStatusStatusEnum getStatus() { + public StatusFd5Enum getStatus() { return status; } @@ -108,6 +126,8 @@ private boolean equalTo(SyncStatus other) { && modelId.equals(other.modelId) && lastSyncStart.equals(other.lastSyncStart) && nextSyncStart.equals(other.nextSyncStart) + && lastSyncResult.equals(other.lastSyncResult) + && lastSyncFinished.equals(other.lastSyncFinished) && status.equals(other.status) && isInitialSync == other.isInitialSync && selectiveSyncConfigurationsUsage.equals(other.selectiveSyncConfigurationsUsage); @@ -120,6 +140,8 @@ public int hashCode() { this.modelId, this.lastSyncStart, this.nextSyncStart, + this.lastSyncResult, + this.lastSyncFinished, this.status, this.isInitialSync, this.selectiveSyncConfigurationsUsage); @@ -145,7 +167,7 @@ public interface ModelIdStage { } public interface StatusStage { - IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status); + IsInitialSyncStage status(@NotNull StatusFd5Enum status); } public interface IsInitialSyncStage { @@ -163,6 +185,14 @@ public interface _FinalStage { _FinalStage nextSyncStart(OffsetDateTime nextSyncStart); + _FinalStage lastSyncResult(Optional lastSyncResult); + + _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult); + + _FinalStage lastSyncFinished(Optional lastSyncFinished); + + _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished); + _FinalStage selectiveSyncConfigurationsUsage( Optional selectiveSyncConfigurationsUsage); @@ -177,12 +207,16 @@ public static final class Builder private String modelId; - private SyncStatusStatusEnum status; + private StatusFd5Enum status; private boolean isInitialSync; private Optional selectiveSyncConfigurationsUsage = Optional.empty(); + private Optional lastSyncFinished = Optional.empty(); + + private Optional lastSyncResult = Optional.empty(); + private Optional nextSyncStart = Optional.empty(); private Optional lastSyncStart = Optional.empty(); @@ -198,6 +232,8 @@ public Builder from(SyncStatus other) { modelId(other.getModelId()); lastSyncStart(other.getLastSyncStart()); nextSyncStart(other.getNextSyncStart()); + lastSyncResult(other.getLastSyncResult()); + lastSyncFinished(other.getLastSyncFinished()); status(other.getStatus()); isInitialSync(other.getIsInitialSync()); selectiveSyncConfigurationsUsage(other.getSelectiveSyncConfigurationsUsage()); @@ -220,7 +256,7 @@ public StatusStage modelId(@NotNull String modelId) { @java.lang.Override @JsonSetter("status") - public IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status) { + public IsInitialSyncStage status(@NotNull StatusFd5Enum status) { this.status = status; return this; } @@ -247,6 +283,32 @@ public _FinalStage selectiveSyncConfigurationsUsage( return this; } + @java.lang.Override + public _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished) { + this.lastSyncFinished = Optional.ofNullable(lastSyncFinished); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_finished", nulls = Nulls.SKIP) + public _FinalStage lastSyncFinished(Optional lastSyncFinished) { + this.lastSyncFinished = lastSyncFinished; + return this; + } + + @java.lang.Override + public _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult) { + this.lastSyncResult = Optional.ofNullable(lastSyncResult); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_result", nulls = Nulls.SKIP) + public _FinalStage lastSyncResult(Optional lastSyncResult) { + this.lastSyncResult = lastSyncResult; + return this; + } + @java.lang.Override public _FinalStage nextSyncStart(OffsetDateTime nextSyncStart) { this.nextSyncStart = Optional.ofNullable(nextSyncStart); @@ -280,6 +342,8 @@ public SyncStatus build() { modelId, lastSyncStart, nextSyncStart, + lastSyncResult, + lastSyncFinished, status, isInitialSync, selectiveSyncConfigurationsUsage, diff --git a/src/main/java/com/merge/api/resources/accounting/types/SyncStatusStatusEnum.java b/src/main/java/com/merge/api/resources/accounting/types/SyncStatusStatusEnum.java deleted file mode 100644 index e8dc76f71..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/SyncStatusStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SyncStatusStatusEnum { - SYNCING("SYNCING"), - - DONE("DONE"), - - FAILED("FAILED"), - - DISABLED("DISABLED"), - - PAUSED("PAUSED"), - - PARTIALLY_SYNCED("PARTIALLY_SYNCED"); - - private final String value; - - SyncStatusStatusEnum(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/TaxComponent.java b/src/main/java/com/merge/api/resources/accounting/types/TaxComponent.java index 72c5b4be6..8704a298d 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/TaxComponent.java +++ b/src/main/java/com/merge/api/resources/accounting/types/TaxComponent.java @@ -35,7 +35,7 @@ public final class TaxComponent { private final Optional isCompound; - private final Optional componentType; + private final Optional componentType; private final Optional remoteWasDeleted; @@ -49,7 +49,7 @@ private TaxComponent( Optional name, Optional rate, Optional isCompound, - Optional componentType, + Optional componentType, Optional remoteWasDeleted, Map additionalProperties) { this.id = id; @@ -125,7 +125,7 @@ public Optional getIsCompound() { * */ @JsonProperty("component_type") - public Optional getComponentType() { + public Optional getComponentType() { return componentType; } @@ -199,7 +199,7 @@ public static final class Builder { private Optional isCompound = Optional.empty(); - private Optional componentType = Optional.empty(); + private Optional componentType = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -299,12 +299,12 @@ public Builder isCompound(Boolean isCompound) { } @JsonSetter(value = "component_type", nulls = Nulls.SKIP) - public Builder componentType(Optional componentType) { + public Builder componentType(Optional componentType) { this.componentType = componentType; return this; } - public Builder componentType(TaxComponentComponentType componentType) { + public Builder componentType(ComponentTypeEnum componentType) { this.componentType = Optional.ofNullable(componentType); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/TaxComponentComponentType.java b/src/main/java/com/merge/api/resources/accounting/types/TaxComponentComponentType.java deleted file mode 100644 index 33e3f273d..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/TaxComponentComponentType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TaxComponentComponentType.Deserializer.class) -public final class TaxComponentComponentType { - private final Object value; - - private final int type; - - private TaxComponentComponentType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ComponentTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TaxComponentComponentType && equalTo((TaxComponentComponentType) other); - } - - private boolean equalTo(TaxComponentComponentType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TaxComponentComponentType of(ComponentTypeEnum value) { - return new TaxComponentComponentType(value, 0); - } - - public static TaxComponentComponentType of(String value) { - return new TaxComponentComponentType(value, 1); - } - - public interface Visitor { - T visit(ComponentTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TaxComponentComponentType.class); - } - - @java.lang.Override - public TaxComponentComponentType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ComponentTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/TaxRate.java b/src/main/java/com/merge/api/resources/accounting/types/TaxRate.java index 67362252a..5d88d758d 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/TaxRate.java +++ b/src/main/java/com/merge/api/resources/accounting/types/TaxRate.java @@ -39,7 +39,7 @@ public final class TaxRate { private final Optional description; - private final Optional status; + private final Optional status; private final Optional country; @@ -66,7 +66,7 @@ private TaxRate( Optional code, Optional name, Optional description, - Optional status, + Optional status, Optional country, Optional totalTaxRate, Optional effectiveTaxRate, @@ -163,7 +163,7 @@ public Optional getDescription() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -295,7 +295,7 @@ public static final class Builder { private Optional description = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional country = Optional.empty(); @@ -425,12 +425,12 @@ public Builder description(String description) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(TaxRateStatus status) { + public Builder status(Status7D1Enum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/TaxRateCompany.java b/src/main/java/com/merge/api/resources/accounting/types/TaxRateCompany.java index 3df649887..04548be91 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/TaxRateCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/TaxRateCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TaxRateCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TaxRateCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/TaxRateStatus.java b/src/main/java/com/merge/api/resources/accounting/types/TaxRateStatus.java deleted file mode 100644 index 8f83fc9fd..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/TaxRateStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TaxRateStatus.Deserializer.class) -public final class TaxRateStatus { - private final Object value; - - private final int type; - - private TaxRateStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Status7D1Enum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TaxRateStatus && equalTo((TaxRateStatus) other); - } - - private boolean equalTo(TaxRateStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TaxRateStatus of(Status7D1Enum value) { - return new TaxRateStatus(value, 0); - } - - public static TaxRateStatus of(String value) { - return new TaxRateStatus(value, 1); - } - - public interface Visitor { - T visit(Status7D1Enum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TaxRateStatus.class); - } - - @java.lang.Override - public TaxRateStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, Status7D1Enum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/TaxRateTaxComponentsItem.java b/src/main/java/com/merge/api/resources/accounting/types/TaxRateTaxComponentsItem.java index d4c4a31cb..583588fb7 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/TaxRateTaxComponentsItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/TaxRateTaxComponentsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer name; - private final Optional status; + private final Optional status; - private final Optional categoryType; + private final Optional categoryType; private final Optional parentCategory; @@ -52,8 +52,8 @@ private TrackingCategory( Optional createdAt, Optional modifiedAt, Optional name, - Optional status, - Optional categoryType, + Optional status, + Optional categoryType, Optional parentCategory, Optional company, Optional remoteWasDeleted, @@ -118,7 +118,7 @@ public Optional getName() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -130,7 +130,7 @@ public Optional getStatus() { * */ @JsonProperty("category_type") - public Optional getCategoryType() { + public Optional getCategoryType() { return categoryType; } @@ -222,9 +222,9 @@ public static final class Builder { private Optional name = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); - private Optional categoryType = Optional.empty(); + private Optional categoryType = Optional.empty(); private Optional parentCategory = Optional.empty(); @@ -310,23 +310,23 @@ public Builder name(String name) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(TrackingCategoryStatus status) { + public Builder status(Status7D1Enum status) { this.status = Optional.ofNullable(status); return this; } @JsonSetter(value = "category_type", nulls = Nulls.SKIP) - public Builder categoryType(Optional categoryType) { + public Builder categoryType(Optional categoryType) { this.categoryType = categoryType; return this; } - public Builder categoryType(TrackingCategoryCategoryType categoryType) { + public Builder categoryType(CategoryTypeEnum categoryType) { this.categoryType = Optional.ofNullable(categoryType); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/TrackingCategoryCategoryType.java b/src/main/java/com/merge/api/resources/accounting/types/TrackingCategoryCategoryType.java deleted file mode 100644 index a0a4c63b4..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/TrackingCategoryCategoryType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TrackingCategoryCategoryType.Deserializer.class) -public final class TrackingCategoryCategoryType { - private final Object value; - - private final int type; - - private TrackingCategoryCategoryType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CategoryTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TrackingCategoryCategoryType && equalTo((TrackingCategoryCategoryType) other); - } - - private boolean equalTo(TrackingCategoryCategoryType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TrackingCategoryCategoryType of(CategoryTypeEnum value) { - return new TrackingCategoryCategoryType(value, 0); - } - - public static TrackingCategoryCategoryType of(String value) { - return new TrackingCategoryCategoryType(value, 1); - } - - public interface Visitor { - T visit(CategoryTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TrackingCategoryCategoryType.class); - } - - @java.lang.Override - public TrackingCategoryCategoryType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CategoryTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/TrackingCategoryCompany.java b/src/main/java/com/merge/api/resources/accounting/types/TrackingCategoryCompany.java index 6a37335b4..b6f08fd82 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/TrackingCategoryCompany.java +++ b/src/main/java/com/merge/api/resources/accounting/types/TrackingCategoryCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public TrackingCategoryCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TrackingCategoryCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/TrackingCategoryStatus.java b/src/main/java/com/merge/api/resources/accounting/types/TrackingCategoryStatus.java deleted file mode 100644 index 4665e92c1..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/TrackingCategoryStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TrackingCategoryStatus.Deserializer.class) -public final class TrackingCategoryStatus { - private final Object value; - - private final int type; - - private TrackingCategoryStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Status7D1Enum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TrackingCategoryStatus && equalTo((TrackingCategoryStatus) other); - } - - private boolean equalTo(TrackingCategoryStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TrackingCategoryStatus of(Status7D1Enum value) { - return new TrackingCategoryStatus(value, 0); - } - - public static TrackingCategoryStatus of(String value) { - return new TrackingCategoryStatus(value, 1); - } - - public interface Visitor { - T visit(Status7D1Enum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TrackingCategoryStatus.class); - } - - @java.lang.Override - public TrackingCategoryStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, Status7D1Enum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/Transaction.java b/src/main/java/com/merge/api/resources/accounting/types/Transaction.java index ac5ca3814..73100acc7 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/Transaction.java +++ b/src/main/java/com/merge/api/resources/accounting/types/Transaction.java @@ -45,7 +45,7 @@ public final class Transaction { private final Optional totalAmount; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -77,7 +77,7 @@ private Transaction( Optional contact, Optional inclusiveOfTax, Optional totalAmount, - Optional currency, + Optional currency, Optional exchangeRate, Optional company, Optional>> trackingCategories, @@ -507,7 +507,7 @@ public Optional getTotalAmount() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -655,7 +655,7 @@ public static final class Builder { private Optional totalAmount = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -824,12 +824,12 @@ public Builder totalAmount(String totalAmount) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(TransactionCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/TransactionAccount.java b/src/main/java/com/merge/api/resources/accounting/types/TransactionAccount.java index 574689359..6a28e2d75 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/TransactionAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/TransactionAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TransactionAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TransactionAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/TransactionAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/TransactionAccountingPeriod.java index 0e45ce92e..ef4a122e1 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/TransactionAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/TransactionAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TransactionContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TransactionContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/TransactionCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/TransactionCurrency.java deleted file mode 100644 index d006f83bd..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/TransactionCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TransactionCurrency.Deserializer.class) -public final class TransactionCurrency { - private final Object value; - - private final int type; - - private TransactionCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TransactionCurrency && equalTo((TransactionCurrency) other); - } - - private boolean equalTo(TransactionCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TransactionCurrency of(TransactionCurrencyEnum value) { - return new TransactionCurrency(value, 0); - } - - public static TransactionCurrency of(String value) { - return new TransactionCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TransactionCurrency.class); - } - - @java.lang.Override - public TransactionCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItem.java b/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItem.java index 4ca05a09f..9eb6b6a42 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItem.java @@ -48,7 +48,7 @@ public final class TransactionLineItem { private final Optional taxRate; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -72,7 +72,7 @@ private TransactionLineItem( Optional>> trackingCategories, Optional totalLineAmount, Optional taxRate, - Optional currency, + Optional currency, Optional exchangeRate, Optional company, Optional remoteWasDeleted, @@ -507,7 +507,7 @@ public Optional getTaxRate() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -625,7 +625,7 @@ public static final class Builder { private Optional taxRate = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -803,12 +803,12 @@ public Builder taxRate(String taxRate) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(TransactionLineItemCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItemCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItemCurrency.java deleted file mode 100644 index f2a01c301..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItemCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TransactionLineItemCurrency.Deserializer.class) -public final class TransactionLineItemCurrency { - private final Object value; - - private final int type; - - private TransactionLineItemCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TransactionLineItemCurrency && equalTo((TransactionLineItemCurrency) other); - } - - private boolean equalTo(TransactionLineItemCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TransactionLineItemCurrency of(TransactionCurrencyEnum value) { - return new TransactionLineItemCurrency(value, 0); - } - - public static TransactionLineItemCurrency of(String value) { - return new TransactionLineItemCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TransactionLineItemCurrency.class); - } - - @java.lang.Override - public TransactionLineItemCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItemItem.java b/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItemItem.java index 89c29ffd3..9116e7d4c 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItemItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/TransactionLineItemItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public TransactionLineItemItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TransactionLineItemItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/TransactionTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/TransactionTrackingCategoriesItem.java index 51acb87f2..1aaaf4b5f 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/TransactionTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/TransactionTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer totalAmount; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -72,7 +72,7 @@ private VendorCredit( Optional transactionDate, Optional vendor, Optional totalAmount, - Optional currency, + Optional currency, Optional exchangeRate, Optional inclusiveOfTax, Optional company, @@ -479,7 +479,7 @@ public Optional getTotalAmount() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -635,7 +635,7 @@ public static final class Builder { private Optional totalAmount = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -774,12 +774,12 @@ public Builder totalAmount(Double totalAmount) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(VendorCreditCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditAccountingPeriod.java index 43099b29e..b6290bf91 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,8 +80,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public VendorCreditCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public VendorCreditCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditCurrency.java b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditCurrency.java deleted file mode 100644 index 418568614..000000000 --- a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = VendorCreditCurrency.Deserializer.class) -public final class VendorCreditCurrency { - private final Object value; - - private final int type; - - private VendorCreditCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof VendorCreditCurrency && equalTo((VendorCreditCurrency) other); - } - - private boolean equalTo(VendorCreditCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static VendorCreditCurrency of(TransactionCurrencyEnum value) { - return new VendorCreditCurrency(value, 0); - } - - public static VendorCreditCurrency of(String value) { - return new VendorCreditCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(VendorCreditCurrency.class); - } - - @java.lang.Override - public VendorCreditCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditLineAccount.java b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditLineAccount.java index 4f043e195..ce290884d 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditLineAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditLineAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public VendorCreditLineAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public VendorCreditLineAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditLineRequestAccount.java b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditLineRequestAccount.java index 2cd0d1391..4d88a6c99 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditLineRequestAccount.java +++ b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditLineRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer totalAmount; - private final Optional currency; + private final Optional currency; private final Optional exchangeRate; @@ -56,7 +56,7 @@ private VendorCreditRequest( Optional transactionDate, Optional vendor, Optional totalAmount, - Optional currency, + Optional currency, Optional exchangeRate, Optional inclusiveOfTax, Optional company, @@ -426,7 +426,7 @@ public Optional getTotalAmount() { * */ @JsonProperty("currency") - public Optional getCurrency() { + public Optional getCurrency() { return currency; } @@ -549,7 +549,7 @@ public static final class Builder { private Optional totalAmount = Optional.empty(); - private Optional currency = Optional.empty(); + private Optional currency = Optional.empty(); private Optional exchangeRate = Optional.empty(); @@ -635,12 +635,12 @@ public Builder totalAmount(Double totalAmount) { } @JsonSetter(value = "currency", nulls = Nulls.SKIP) - public Builder currency(Optional currency) { + public Builder currency(Optional currency) { this.currency = currency; return this; } - public Builder currency(VendorCreditRequestCurrency currency) { + public Builder currency(TransactionCurrencyEnum currency) { this.currency = Optional.ofNullable(currency); return this; } diff --git a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditRequestAccountingPeriod.java b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditRequestAccountingPeriod.java index 17d40f347..cecb8593c 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditRequestAccountingPeriod.java +++ b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditRequestAccountingPeriod.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TransactionCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof VendorCreditRequestCurrency && equalTo((VendorCreditRequestCurrency) other); - } - - private boolean equalTo(VendorCreditRequestCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static VendorCreditRequestCurrency of(TransactionCurrencyEnum value) { - return new VendorCreditRequestCurrency(value, 0); - } - - public static VendorCreditRequestCurrency of(String value) { - return new VendorCreditRequestCurrency(value, 1); - } - - public interface Visitor { - T visit(TransactionCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(VendorCreditRequestCurrency.class); - } - - @java.lang.Override - public VendorCreditRequestCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TransactionCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditRequestTrackingCategoriesItem.java b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditRequestTrackingCategoriesItem.java index c8e5cda3a..8db18d34f 100644 --- a/src/main/java/com/merge/api/resources/accounting/types/VendorCreditRequestTrackingCategoriesItem.java +++ b/src/main/java/com/merge/api/resources/accounting/types/VendorCreditRequestTrackingCategoriesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public VendorCreditVendor deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public VendorCreditVendor deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/accounting/vendorcredits/AsyncRawVendorCreditsClient.java b/src/main/java/com/merge/api/resources/accounting/vendorcredits/AsyncRawVendorCreditsClient.java new file mode 100644 index 000000000..10c1df40f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/vendorcredits/AsyncRawVendorCreditsClient.java @@ -0,0 +1,396 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.vendorcredits; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedVendorCreditList; +import com.merge.api.resources.accounting.types.VendorCredit; +import com.merge.api.resources.accounting.types.VendorCreditResponse; +import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditEndpointRequest; +import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditsListRequest; +import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditsRetrieveRequest; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawVendorCreditsClient { + protected final ClientOptions clientOptions; + + public AsyncRawVendorCreditsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of VendorCredit objects. + */ + public CompletableFuture> list() { + return list(VendorCreditsListRequest.builder().build()); + } + + /** + * Returns a list of VendorCredit objects. + */ + public CompletableFuture> list(VendorCreditsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of VendorCredit objects. + */ + public CompletableFuture> list( + VendorCreditsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/vendor-credits"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedVendorCreditList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a VendorCredit object with the given values. + */ + public CompletableFuture> create(VendorCreditEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a VendorCredit object with the given values. + */ + public CompletableFuture> create( + VendorCreditEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/vendor-credits"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), VendorCreditResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a VendorCredit object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, VendorCreditsRetrieveRequest.builder().build()); + } + + /** + * Returns a VendorCredit object with the given id. + */ + public CompletableFuture> retrieve( + String id, VendorCreditsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a VendorCredit object with the given id. + */ + public CompletableFuture> retrieve( + String id, VendorCreditsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/vendor-credits") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), VendorCredit.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for VendorCredit POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for VendorCredit POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/vendor-credits/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/vendorcredits/AsyncVendorCreditsClient.java b/src/main/java/com/merge/api/resources/accounting/vendorcredits/AsyncVendorCreditsClient.java new file mode 100644 index 000000000..9ec993a0f --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/vendorcredits/AsyncVendorCreditsClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.vendorcredits; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedVendorCreditList; +import com.merge.api.resources.accounting.types.VendorCredit; +import com.merge.api.resources.accounting.types.VendorCreditResponse; +import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditEndpointRequest; +import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditsListRequest; +import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditsRetrieveRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncVendorCreditsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawVendorCreditsClient rawClient; + + public AsyncVendorCreditsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawVendorCreditsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawVendorCreditsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of VendorCredit objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of VendorCredit objects. + */ + public CompletableFuture list(VendorCreditsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of VendorCredit objects. + */ + public CompletableFuture list( + VendorCreditsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a VendorCredit object with the given values. + */ + public CompletableFuture create(VendorCreditEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a VendorCredit object with the given values. + */ + public CompletableFuture create( + VendorCreditEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a VendorCredit object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a VendorCredit object with the given id. + */ + public CompletableFuture retrieve(String id, VendorCreditsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a VendorCredit object with the given id. + */ + public CompletableFuture retrieve( + String id, VendorCreditsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for VendorCredit POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for VendorCredit POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/vendorcredits/RawVendorCreditsClient.java b/src/main/java/com/merge/api/resources/accounting/vendorcredits/RawVendorCreditsClient.java new file mode 100644 index 000000000..292af5e02 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/vendorcredits/RawVendorCreditsClient.java @@ -0,0 +1,336 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.vendorcredits; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.MetaResponse; +import com.merge.api.resources.accounting.types.PaginatedVendorCreditList; +import com.merge.api.resources.accounting.types.VendorCredit; +import com.merge.api.resources.accounting.types.VendorCreditResponse; +import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditEndpointRequest; +import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditsListRequest; +import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditsRetrieveRequest; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawVendorCreditsClient { + protected final ClientOptions clientOptions; + + public RawVendorCreditsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of VendorCredit objects. + */ + public MergeApiHttpResponse list() { + return list(VendorCreditsListRequest.builder().build()); + } + + /** + * Returns a list of VendorCredit objects. + */ + public MergeApiHttpResponse list(VendorCreditsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of VendorCredit objects. + */ + public MergeApiHttpResponse list( + VendorCreditsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/vendor-credits"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTransactionDateAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_after", + request.getTransactionDateAfter().get().toString(), + false); + } + if (request.getTransactionDateBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "transaction_date_before", + request.getTransactionDateBefore().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedVendorCreditList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a VendorCredit object with the given values. + */ + public MergeApiHttpResponse create(VendorCreditEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a VendorCredit object with the given values. + */ + public MergeApiHttpResponse create( + VendorCreditEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/vendor-credits"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), VendorCreditResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a VendorCredit object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, VendorCreditsRetrieveRequest.builder().build()); + } + + /** + * Returns a VendorCredit object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, VendorCreditsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a VendorCredit object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, VendorCreditsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/vendor-credits") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), VendorCredit.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for VendorCredit POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for VendorCredit POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/vendor-credits/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/vendorcredits/VendorCreditsClient.java b/src/main/java/com/merge/api/resources/accounting/vendorcredits/VendorCreditsClient.java index 0da694ae4..c6e4a1d77 100644 --- a/src/main/java/com/merge/api/resources/accounting/vendorcredits/VendorCreditsClient.java +++ b/src/main/java/com/merge/api/resources/accounting/vendorcredits/VendorCreditsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.accounting.vendorcredits; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.types.MetaResponse; import com.merge.api.resources.accounting.types.PaginatedVendorCreditList; @@ -16,274 +12,91 @@ import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditEndpointRequest; import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditsListRequest; import com.merge.api.resources.accounting.vendorcredits.requests.VendorCreditsRetrieveRequest; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class VendorCreditsClient { protected final ClientOptions clientOptions; + private final RawVendorCreditsClient rawClient; + public VendorCreditsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawVendorCreditsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawVendorCreditsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of VendorCredit objects. */ public PaginatedVendorCreditList list() { - return list(VendorCreditsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of VendorCredit objects. */ public PaginatedVendorCreditList list(VendorCreditsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of VendorCredit objects. */ public PaginatedVendorCreditList list(VendorCreditsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/vendor-credits"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getTransactionDateAfter().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_after", - request.getTransactionDateAfter().get().toString()); - } - if (request.getTransactionDateBefore().isPresent()) { - httpUrl.addQueryParameter( - "transaction_date_before", - request.getTransactionDateBefore().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedVendorCreditList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a VendorCredit object with the given values. */ public VendorCreditResponse create(VendorCreditEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a VendorCredit object with the given values. */ public VendorCreditResponse create(VendorCreditEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/vendor-credits"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), VendorCreditResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a VendorCredit object with the given id. */ public VendorCredit retrieve(String id) { - return retrieve(id, VendorCreditsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a VendorCredit object with the given id. */ public VendorCredit retrieve(String id, VendorCreditsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a VendorCredit object with the given id. */ public VendorCredit retrieve(String id, VendorCreditsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/vendor-credits") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), VendorCredit.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for VendorCredit POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for VendorCredit POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/vendor-credits/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/accounting/vendorcredits/requests/VendorCreditsListRequest.java b/src/main/java/com/merge/api/resources/accounting/vendorcredits/requests/VendorCreditsListRequest.java index 418e12fac..cf1366075 100644 --- a/src/main/java/com/merge/api/resources/accounting/vendorcredits/requests/VendorCreditsListRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/vendorcredits/requests/VendorCreditsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.vendorcredits.types.VendorCreditsListRequestExpand; +import com.merge.api.resources.accounting.vendorcredits.types.VendorCreditsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = VendorCreditsListRequest.Builder.class) public final class VendorCreditsListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -30,8 +34,6 @@ public final class VendorCreditsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -53,11 +55,11 @@ public final class VendorCreditsListRequest { private final Map additionalProperties; private VendorCreditsListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -68,11 +70,11 @@ private VendorCreditsListRequest( Optional transactionDateAfter, Optional transactionDateBefore, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -85,6 +87,14 @@ private VendorCreditsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return vendor credits for this company. */ @@ -117,14 +127,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -209,11 +211,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(VendorCreditsListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -228,11 +230,11 @@ private boolean equalTo(VendorCreditsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -255,6 +257,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -263,8 +267,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -289,11 +291,11 @@ public static final class Builder { private Builder() {} public Builder from(VendorCreditsListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -306,6 +308,22 @@ public Builder from(VendorCreditsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(VendorCreditsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -350,17 +368,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(VendorCreditsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -462,11 +469,11 @@ public Builder transactionDateBefore(OffsetDateTime transactionDateBefore) { public VendorCreditsListRequest build() { return new VendorCreditsListRequest( + expand, companyId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/accounting/vendorcredits/requests/VendorCreditsRetrieveRequest.java b/src/main/java/com/merge/api/resources/accounting/vendorcredits/requests/VendorCreditsRetrieveRequest.java index 8354c2885..62bdadbde 100644 --- a/src/main/java/com/merge/api/resources/accounting/vendorcredits/requests/VendorCreditsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/accounting/vendorcredits/requests/VendorCreditsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.accounting.vendorcredits.types.VendorCreditsRetrieveRequestExpand; +import com.merge.api.resources.accounting.vendorcredits.types.VendorCreditsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = VendorCreditsRetrieveRequest.Builder.class) public final class VendorCreditsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private VendorCreditsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private VendorCreditsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(VendorCreditsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -83,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,20 +113,26 @@ private Builder() {} public Builder from(VendorCreditsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(VendorCreditsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(VendorCreditsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -120,8 +144,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public VendorCreditsRetrieveRequest build() { - return new VendorCreditsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new VendorCreditsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsListRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsListRequestExpand.java deleted file mode 100644 index dac8c0e6f..000000000 --- a/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsListRequestExpand.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.vendorcredits.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum VendorCreditsListRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - LINES("lines"), - - LINES_ACCOUNTING_PERIOD("lines,accounting_period"), - - LINES_COMPANY("lines,company"), - - LINES_COMPANY_ACCOUNTING_PERIOD("lines,company,accounting_period"), - - LINES_TRACKING_CATEGORIES("lines,tracking_categories"), - - LINES_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("lines,tracking_categories,accounting_period"), - - LINES_TRACKING_CATEGORIES_COMPANY("lines,tracking_categories,company"), - - LINES_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("lines,tracking_categories,company,accounting_period"), - - LINES_TRACKING_CATEGORIES_VENDOR("lines,tracking_categories,vendor"), - - LINES_TRACKING_CATEGORIES_VENDOR_ACCOUNTING_PERIOD("lines,tracking_categories,vendor,accounting_period"), - - LINES_TRACKING_CATEGORIES_VENDOR_COMPANY("lines,tracking_categories,vendor,company"), - - LINES_TRACKING_CATEGORIES_VENDOR_COMPANY_ACCOUNTING_PERIOD( - "lines,tracking_categories,vendor,company,accounting_period"), - - LINES_VENDOR("lines,vendor"), - - LINES_VENDOR_ACCOUNTING_PERIOD("lines,vendor,accounting_period"), - - LINES_VENDOR_COMPANY("lines,vendor,company"), - - LINES_VENDOR_COMPANY_ACCOUNTING_PERIOD("lines,vendor,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_VENDOR("tracking_categories,vendor"), - - TRACKING_CATEGORIES_VENDOR_ACCOUNTING_PERIOD("tracking_categories,vendor,accounting_period"), - - TRACKING_CATEGORIES_VENDOR_COMPANY("tracking_categories,vendor,company"), - - TRACKING_CATEGORIES_VENDOR_COMPANY_ACCOUNTING_PERIOD("tracking_categories,vendor,company,accounting_period"), - - VENDOR("vendor"), - - VENDOR_ACCOUNTING_PERIOD("vendor,accounting_period"), - - VENDOR_COMPANY("vendor,company"), - - VENDOR_COMPANY_ACCOUNTING_PERIOD("vendor,company,accounting_period"); - - private final String value; - - VendorCreditsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsListRequestExpandItem.java new file mode 100644 index 000000000..97c8fd89a --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsListRequestExpandItem.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.vendorcredits.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum VendorCreditsListRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + COMPANY("company"), + + LINES("lines"), + + TRACKING_CATEGORIES("tracking_categories"), + + VENDOR("vendor"); + + private final String value; + + VendorCreditsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsRetrieveRequestExpand.java deleted file mode 100644 index 601d58ef5..000000000 --- a/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsRetrieveRequestExpand.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.accounting.vendorcredits.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum VendorCreditsRetrieveRequestExpand { - ACCOUNTING_PERIOD("accounting_period"), - - COMPANY("company"), - - COMPANY_ACCOUNTING_PERIOD("company,accounting_period"), - - LINES("lines"), - - LINES_ACCOUNTING_PERIOD("lines,accounting_period"), - - LINES_COMPANY("lines,company"), - - LINES_COMPANY_ACCOUNTING_PERIOD("lines,company,accounting_period"), - - LINES_TRACKING_CATEGORIES("lines,tracking_categories"), - - LINES_TRACKING_CATEGORIES_ACCOUNTING_PERIOD("lines,tracking_categories,accounting_period"), - - LINES_TRACKING_CATEGORIES_COMPANY("lines,tracking_categories,company"), - - LINES_TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("lines,tracking_categories,company,accounting_period"), - - LINES_TRACKING_CATEGORIES_VENDOR("lines,tracking_categories,vendor"), - - LINES_TRACKING_CATEGORIES_VENDOR_ACCOUNTING_PERIOD("lines,tracking_categories,vendor,accounting_period"), - - LINES_TRACKING_CATEGORIES_VENDOR_COMPANY("lines,tracking_categories,vendor,company"), - - LINES_TRACKING_CATEGORIES_VENDOR_COMPANY_ACCOUNTING_PERIOD( - "lines,tracking_categories,vendor,company,accounting_period"), - - LINES_VENDOR("lines,vendor"), - - LINES_VENDOR_ACCOUNTING_PERIOD("lines,vendor,accounting_period"), - - LINES_VENDOR_COMPANY("lines,vendor,company"), - - LINES_VENDOR_COMPANY_ACCOUNTING_PERIOD("lines,vendor,company,accounting_period"), - - TRACKING_CATEGORIES("tracking_categories"), - - TRACKING_CATEGORIES_ACCOUNTING_PERIOD("tracking_categories,accounting_period"), - - TRACKING_CATEGORIES_COMPANY("tracking_categories,company"), - - TRACKING_CATEGORIES_COMPANY_ACCOUNTING_PERIOD("tracking_categories,company,accounting_period"), - - TRACKING_CATEGORIES_VENDOR("tracking_categories,vendor"), - - TRACKING_CATEGORIES_VENDOR_ACCOUNTING_PERIOD("tracking_categories,vendor,accounting_period"), - - TRACKING_CATEGORIES_VENDOR_COMPANY("tracking_categories,vendor,company"), - - TRACKING_CATEGORIES_VENDOR_COMPANY_ACCOUNTING_PERIOD("tracking_categories,vendor,company,accounting_period"), - - VENDOR("vendor"), - - VENDOR_ACCOUNTING_PERIOD("vendor,accounting_period"), - - VENDOR_COMPANY("vendor,company"), - - VENDOR_COMPANY_ACCOUNTING_PERIOD("vendor,company,accounting_period"); - - private final String value; - - VendorCreditsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..4764edfa1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/vendorcredits/types/VendorCreditsRetrieveRequestExpandItem.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.vendorcredits.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum VendorCreditsRetrieveRequestExpandItem { + ACCOUNTING_PERIOD("accounting_period"), + + COMPANY("company"), + + LINES("lines"), + + TRACKING_CATEGORIES("tracking_categories"), + + VENDOR("vendor"); + + private final String value; + + VendorCreditsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/webhookreceivers/AsyncRawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/accounting/webhookreceivers/AsyncRawWebhookReceiversClient.java new file mode 100644 index 000000000..12a1fe68e --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/webhookreceivers/AsyncRawWebhookReceiversClient.java @@ -0,0 +1,160 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.WebhookReceiver; +import com.merge.api.resources.accounting.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public AsyncRawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create( + WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/webhookreceivers/AsyncWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/accounting/webhookreceivers/AsyncWebhookReceiversClient.java new file mode 100644 index 000000000..53afed402 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/webhookreceivers/AsyncWebhookReceiversClient.java @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.webhookreceivers; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.WebhookReceiver; +import com.merge.api.resources.accounting.webhookreceivers.requests.WebhookReceiverRequest; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncWebhookReceiversClient { + protected final ClientOptions clientOptions; + + private final AsyncRawWebhookReceiversClient rawClient; + + public AsyncWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawWebhookReceiversClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/webhookreceivers/RawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/accounting/webhookreceivers/RawWebhookReceiversClient.java new file mode 100644 index 000000000..8584da741 --- /dev/null +++ b/src/main/java/com/merge/api/resources/accounting/webhookreceivers/RawWebhookReceiversClient.java @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.accounting.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.accounting.types.WebhookReceiver; +import com.merge.api.resources.accounting.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public RawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("accounting/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/accounting/webhookreceivers/WebhookReceiversClient.java b/src/main/java/com/merge/api/resources/accounting/webhookreceivers/WebhookReceiversClient.java index 565302c25..a86c4a67d 100644 --- a/src/main/java/com/merge/api/resources/accounting/webhookreceivers/WebhookReceiversClient.java +++ b/src/main/java/com/merge/api/resources/accounting/webhookreceivers/WebhookReceiversClient.java @@ -3,120 +3,54 @@ */ package com.merge.api.resources.accounting.webhookreceivers; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.accounting.types.WebhookReceiver; import com.merge.api.resources.accounting.webhookreceivers.requests.WebhookReceiverRequest; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class WebhookReceiversClient { protected final ClientOptions clientOptions; + private final RawWebhookReceiversClient rawClient; + public WebhookReceiversClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawWebhookReceiversClient withRawResponse() { + return this.rawClient; } /** * Returns a list of WebhookReceiver objects. */ public List list() { - return list(null); + return this.rawClient.list().body(); } /** * Returns a list of WebhookReceiver objects. */ public List list(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/webhook-receivers") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(requestOptions).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("accounting/v1/webhook-receivers") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/AsyncAtsClient.java b/src/main/java/com/merge/api/resources/ats/AsyncAtsClient.java new file mode 100644 index 000000000..a5973ceee --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/AsyncAtsClient.java @@ -0,0 +1,280 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.Suppliers; +import com.merge.api.resources.ats.accountdetails.AsyncAccountDetailsClient; +import com.merge.api.resources.ats.accounttoken.AsyncAccountTokenClient; +import com.merge.api.resources.ats.activities.AsyncActivitiesClient; +import com.merge.api.resources.ats.applications.AsyncApplicationsClient; +import com.merge.api.resources.ats.asyncpassthrough.AsyncAsyncPassthroughClient; +import com.merge.api.resources.ats.attachments.AsyncAttachmentsClient; +import com.merge.api.resources.ats.audittrail.AsyncAuditTrailClient; +import com.merge.api.resources.ats.availableactions.AsyncAvailableActionsClient; +import com.merge.api.resources.ats.candidates.AsyncCandidatesClient; +import com.merge.api.resources.ats.deleteaccount.AsyncDeleteAccountClient; +import com.merge.api.resources.ats.departments.AsyncDepartmentsClient; +import com.merge.api.resources.ats.eeocs.AsyncEeocsClient; +import com.merge.api.resources.ats.fieldmapping.AsyncFieldMappingClient; +import com.merge.api.resources.ats.forceresync.AsyncForceResyncClient; +import com.merge.api.resources.ats.generatekey.AsyncGenerateKeyClient; +import com.merge.api.resources.ats.interviews.AsyncInterviewsClient; +import com.merge.api.resources.ats.issues.AsyncIssuesClient; +import com.merge.api.resources.ats.jobinterviewstages.AsyncJobInterviewStagesClient; +import com.merge.api.resources.ats.jobpostings.AsyncJobPostingsClient; +import com.merge.api.resources.ats.jobs.AsyncJobsClient; +import com.merge.api.resources.ats.linkedaccounts.AsyncLinkedAccountsClient; +import com.merge.api.resources.ats.linktoken.AsyncLinkTokenClient; +import com.merge.api.resources.ats.offers.AsyncOffersClient; +import com.merge.api.resources.ats.offices.AsyncOfficesClient; +import com.merge.api.resources.ats.passthrough.AsyncPassthroughClient; +import com.merge.api.resources.ats.regeneratekey.AsyncRegenerateKeyClient; +import com.merge.api.resources.ats.rejectreasons.AsyncRejectReasonsClient; +import com.merge.api.resources.ats.scopes.AsyncScopesClient; +import com.merge.api.resources.ats.scorecards.AsyncScorecardsClient; +import com.merge.api.resources.ats.syncstatus.AsyncSyncStatusClient; +import com.merge.api.resources.ats.tags.AsyncTagsClient; +import com.merge.api.resources.ats.users.AsyncUsersClient; +import com.merge.api.resources.ats.webhookreceivers.AsyncWebhookReceiversClient; +import java.util.function.Supplier; + +public class AsyncAtsClient { + protected final ClientOptions clientOptions; + + protected final Supplier accountDetailsClient; + + protected final Supplier accountTokenClient; + + protected final Supplier activitiesClient; + + protected final Supplier applicationsClient; + + protected final Supplier asyncPassthroughClient; + + protected final Supplier attachmentsClient; + + protected final Supplier auditTrailClient; + + protected final Supplier availableActionsClient; + + protected final Supplier candidatesClient; + + protected final Supplier scopesClient; + + protected final Supplier deleteAccountClient; + + protected final Supplier departmentsClient; + + protected final Supplier eeocsClient; + + protected final Supplier fieldMappingClient; + + protected final Supplier generateKeyClient; + + protected final Supplier interviewsClient; + + protected final Supplier issuesClient; + + protected final Supplier jobInterviewStagesClient; + + protected final Supplier jobPostingsClient; + + protected final Supplier jobsClient; + + protected final Supplier linkTokenClient; + + protected final Supplier linkedAccountsClient; + + protected final Supplier offersClient; + + protected final Supplier officesClient; + + protected final Supplier passthroughClient; + + protected final Supplier regenerateKeyClient; + + protected final Supplier rejectReasonsClient; + + protected final Supplier scorecardsClient; + + protected final Supplier syncStatusClient; + + protected final Supplier forceResyncClient; + + protected final Supplier tagsClient; + + protected final Supplier usersClient; + + protected final Supplier webhookReceiversClient; + + public AsyncAtsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.accountDetailsClient = Suppliers.memoize(() -> new AsyncAccountDetailsClient(clientOptions)); + this.accountTokenClient = Suppliers.memoize(() -> new AsyncAccountTokenClient(clientOptions)); + this.activitiesClient = Suppliers.memoize(() -> new AsyncActivitiesClient(clientOptions)); + this.applicationsClient = Suppliers.memoize(() -> new AsyncApplicationsClient(clientOptions)); + this.asyncPassthroughClient = Suppliers.memoize(() -> new AsyncAsyncPassthroughClient(clientOptions)); + this.attachmentsClient = Suppliers.memoize(() -> new AsyncAttachmentsClient(clientOptions)); + this.auditTrailClient = Suppliers.memoize(() -> new AsyncAuditTrailClient(clientOptions)); + this.availableActionsClient = Suppliers.memoize(() -> new AsyncAvailableActionsClient(clientOptions)); + this.candidatesClient = Suppliers.memoize(() -> new AsyncCandidatesClient(clientOptions)); + this.scopesClient = Suppliers.memoize(() -> new AsyncScopesClient(clientOptions)); + this.deleteAccountClient = Suppliers.memoize(() -> new AsyncDeleteAccountClient(clientOptions)); + this.departmentsClient = Suppliers.memoize(() -> new AsyncDepartmentsClient(clientOptions)); + this.eeocsClient = Suppliers.memoize(() -> new AsyncEeocsClient(clientOptions)); + this.fieldMappingClient = Suppliers.memoize(() -> new AsyncFieldMappingClient(clientOptions)); + this.generateKeyClient = Suppliers.memoize(() -> new AsyncGenerateKeyClient(clientOptions)); + this.interviewsClient = Suppliers.memoize(() -> new AsyncInterviewsClient(clientOptions)); + this.issuesClient = Suppliers.memoize(() -> new AsyncIssuesClient(clientOptions)); + this.jobInterviewStagesClient = Suppliers.memoize(() -> new AsyncJobInterviewStagesClient(clientOptions)); + this.jobPostingsClient = Suppliers.memoize(() -> new AsyncJobPostingsClient(clientOptions)); + this.jobsClient = Suppliers.memoize(() -> new AsyncJobsClient(clientOptions)); + this.linkTokenClient = Suppliers.memoize(() -> new AsyncLinkTokenClient(clientOptions)); + this.linkedAccountsClient = Suppliers.memoize(() -> new AsyncLinkedAccountsClient(clientOptions)); + this.offersClient = Suppliers.memoize(() -> new AsyncOffersClient(clientOptions)); + this.officesClient = Suppliers.memoize(() -> new AsyncOfficesClient(clientOptions)); + this.passthroughClient = Suppliers.memoize(() -> new AsyncPassthroughClient(clientOptions)); + this.regenerateKeyClient = Suppliers.memoize(() -> new AsyncRegenerateKeyClient(clientOptions)); + this.rejectReasonsClient = Suppliers.memoize(() -> new AsyncRejectReasonsClient(clientOptions)); + this.scorecardsClient = Suppliers.memoize(() -> new AsyncScorecardsClient(clientOptions)); + this.syncStatusClient = Suppliers.memoize(() -> new AsyncSyncStatusClient(clientOptions)); + this.forceResyncClient = Suppliers.memoize(() -> new AsyncForceResyncClient(clientOptions)); + this.tagsClient = Suppliers.memoize(() -> new AsyncTagsClient(clientOptions)); + this.usersClient = Suppliers.memoize(() -> new AsyncUsersClient(clientOptions)); + this.webhookReceiversClient = Suppliers.memoize(() -> new AsyncWebhookReceiversClient(clientOptions)); + } + + public AsyncAccountDetailsClient accountDetails() { + return this.accountDetailsClient.get(); + } + + public AsyncAccountTokenClient accountToken() { + return this.accountTokenClient.get(); + } + + public AsyncActivitiesClient activities() { + return this.activitiesClient.get(); + } + + public AsyncApplicationsClient applications() { + return this.applicationsClient.get(); + } + + public AsyncAsyncPassthroughClient asyncPassthrough() { + return this.asyncPassthroughClient.get(); + } + + public AsyncAttachmentsClient attachments() { + return this.attachmentsClient.get(); + } + + public AsyncAuditTrailClient auditTrail() { + return this.auditTrailClient.get(); + } + + public AsyncAvailableActionsClient availableActions() { + return this.availableActionsClient.get(); + } + + public AsyncCandidatesClient candidates() { + return this.candidatesClient.get(); + } + + public AsyncScopesClient scopes() { + return this.scopesClient.get(); + } + + public AsyncDeleteAccountClient deleteAccount() { + return this.deleteAccountClient.get(); + } + + public AsyncDepartmentsClient departments() { + return this.departmentsClient.get(); + } + + public AsyncEeocsClient eeocs() { + return this.eeocsClient.get(); + } + + public AsyncFieldMappingClient fieldMapping() { + return this.fieldMappingClient.get(); + } + + public AsyncGenerateKeyClient generateKey() { + return this.generateKeyClient.get(); + } + + public AsyncInterviewsClient interviews() { + return this.interviewsClient.get(); + } + + public AsyncIssuesClient issues() { + return this.issuesClient.get(); + } + + public AsyncJobInterviewStagesClient jobInterviewStages() { + return this.jobInterviewStagesClient.get(); + } + + public AsyncJobPostingsClient jobPostings() { + return this.jobPostingsClient.get(); + } + + public AsyncJobsClient jobs() { + return this.jobsClient.get(); + } + + public AsyncLinkTokenClient linkToken() { + return this.linkTokenClient.get(); + } + + public AsyncLinkedAccountsClient linkedAccounts() { + return this.linkedAccountsClient.get(); + } + + public AsyncOffersClient offers() { + return this.offersClient.get(); + } + + public AsyncOfficesClient offices() { + return this.officesClient.get(); + } + + public AsyncPassthroughClient passthrough() { + return this.passthroughClient.get(); + } + + public AsyncRegenerateKeyClient regenerateKey() { + return this.regenerateKeyClient.get(); + } + + public AsyncRejectReasonsClient rejectReasons() { + return this.rejectReasonsClient.get(); + } + + public AsyncScorecardsClient scorecards() { + return this.scorecardsClient.get(); + } + + public AsyncSyncStatusClient syncStatus() { + return this.syncStatusClient.get(); + } + + public AsyncForceResyncClient forceResync() { + return this.forceResyncClient.get(); + } + + public AsyncTagsClient tags() { + return this.tagsClient.get(); + } + + public AsyncUsersClient users() { + return this.usersClient.get(); + } + + public AsyncWebhookReceiversClient webhookReceivers() { + return this.webhookReceiversClient.get(); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/accountdetails/AccountDetailsClient.java b/src/main/java/com/merge/api/resources/ats/accountdetails/AccountDetailsClient.java index 7def09db5..ebcdfcaeb 100644 --- a/src/main/java/com/merge/api/resources/ats/accountdetails/AccountDetailsClient.java +++ b/src/main/java/com/merge/api/resources/ats/accountdetails/AccountDetailsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.ats.accountdetails; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.types.AccountDetails; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountDetailsClient { protected final ClientOptions clientOptions; + private final RawAccountDetailsClient rawClient; + public AccountDetailsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountDetailsClient withRawResponse() { + return this.rawClient; } /** * Get details for a linked account. */ public AccountDetails retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Get details for a linked account. */ public AccountDetails retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/account-details") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/accountdetails/AsyncAccountDetailsClient.java b/src/main/java/com/merge/api/resources/ats/accountdetails/AsyncAccountDetailsClient.java new file mode 100644 index 000000000..039310540 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/accountdetails/AsyncAccountDetailsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.accountdetails; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.AccountDetails; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountDetailsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountDetailsClient rawClient; + + public AsyncAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountDetailsClient withRawResponse() { + return this.rawClient; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/accountdetails/AsyncRawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/ats/accountdetails/AsyncRawAccountDetailsClient.java new file mode 100644 index 000000000..6fe2f66bd --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/accountdetails/AsyncRawAccountDetailsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.AccountDetails; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/accountdetails/RawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/ats/accountdetails/RawAccountDetailsClient.java new file mode 100644 index 000000000..72dfb63e1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/accountdetails/RawAccountDetailsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.AccountDetails; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public RawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/accounttoken/AccountTokenClient.java b/src/main/java/com/merge/api/resources/ats/accounttoken/AccountTokenClient.java index 742d78a6c..1d174ac49 100644 --- a/src/main/java/com/merge/api/resources/ats/accounttoken/AccountTokenClient.java +++ b/src/main/java/com/merge/api/resources/ats/accounttoken/AccountTokenClient.java @@ -3,66 +3,38 @@ */ package com.merge.api.resources.ats.accounttoken; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.types.AccountToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountTokenClient { protected final ClientOptions clientOptions; + private final RawAccountTokenClient rawClient; + public AccountTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountTokenClient withRawResponse() { + return this.rawClient; } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken) { - return retrieve(publicToken, null); + return this.rawClient.retrieve(publicToken).body(); } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/account-token") - .addPathSegment(publicToken) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(publicToken, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/accounttoken/AsyncAccountTokenClient.java b/src/main/java/com/merge/api/resources/ats/accounttoken/AsyncAccountTokenClient.java new file mode 100644 index 000000000..39394b0da --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/accounttoken/AsyncAccountTokenClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.accounttoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.AccountToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountTokenClient rawClient; + + public AsyncAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken) { + return this.rawClient.retrieve(publicToken).thenApply(response -> response.body()); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken, RequestOptions requestOptions) { + return this.rawClient.retrieve(publicToken, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/accounttoken/AsyncRawAccountTokenClient.java b/src/main/java/com/merge/api/resources/ats/accounttoken/AsyncRawAccountTokenClient.java new file mode 100644 index 000000000..9a7030a2f --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/accounttoken/AsyncRawAccountTokenClient.java @@ -0,0 +1,90 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.AccountToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve( + String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/accounttoken/RawAccountTokenClient.java b/src/main/java/com/merge/api/resources/ats/accounttoken/RawAccountTokenClient.java new file mode 100644 index 000000000..af6d2c07f --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/accounttoken/RawAccountTokenClient.java @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.AccountToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountTokenClient { + protected final ClientOptions clientOptions; + + public RawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/activities/ActivitiesClient.java b/src/main/java/com/merge/api/resources/ats/activities/ActivitiesClient.java index 1bf2a51e8..01b9ba2ba 100644 --- a/src/main/java/com/merge/api/resources/ats/activities/ActivitiesClient.java +++ b/src/main/java/com/merge/api/resources/ats/activities/ActivitiesClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.ats.activities; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.activities.requests.ActivitiesListRequest; import com.merge.api.resources.ats.activities.requests.ActivitiesRetrieveRequest; @@ -16,281 +12,91 @@ import com.merge.api.resources.ats.types.ActivityResponse; import com.merge.api.resources.ats.types.MetaResponse; import com.merge.api.resources.ats.types.PaginatedActivityList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ActivitiesClient { protected final ClientOptions clientOptions; + private final RawActivitiesClient rawClient; + public ActivitiesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawActivitiesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawActivitiesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Activity objects. */ public PaginatedActivityList list() { - return list(ActivitiesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Activity objects. */ public PaginatedActivityList list(ActivitiesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Activity objects. */ public PaginatedActivityList list(ActivitiesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/activities"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - if (request.getUserId().isPresent()) { - httpUrl.addQueryParameter("user_id", request.getUserId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedActivityList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates an Activity object with the given values. */ public ActivityResponse create(ActivityEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates an Activity object with the given values. */ public ActivityResponse create(ActivityEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/activities"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - properties.put("remote_user_id", request.getRemoteUserId()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ActivityResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Activity object with the given id. */ public Activity retrieve(String id) { - return retrieve(id, ActivitiesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Activity object with the given id. */ public Activity retrieve(String id, ActivitiesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Activity object with the given id. */ public Activity retrieve(String id, ActivitiesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/activities") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Activity.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for Activity POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Activity POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/activities/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/activities/AsyncActivitiesClient.java b/src/main/java/com/merge/api/resources/ats/activities/AsyncActivitiesClient.java new file mode 100644 index 000000000..7e5e1f2ad --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/activities/AsyncActivitiesClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.activities; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.activities.requests.ActivitiesListRequest; +import com.merge.api.resources.ats.activities.requests.ActivitiesRetrieveRequest; +import com.merge.api.resources.ats.activities.requests.ActivityEndpointRequest; +import com.merge.api.resources.ats.types.Activity; +import com.merge.api.resources.ats.types.ActivityResponse; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedActivityList; +import java.util.concurrent.CompletableFuture; + +public class AsyncActivitiesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawActivitiesClient rawClient; + + public AsyncActivitiesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawActivitiesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawActivitiesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Activity objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Activity objects. + */ + public CompletableFuture list(ActivitiesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Activity objects. + */ + public CompletableFuture list(ActivitiesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Activity object with the given values. + */ + public CompletableFuture create(ActivityEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Activity object with the given values. + */ + public CompletableFuture create(ActivityEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Activity object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Activity object with the given id. + */ + public CompletableFuture retrieve(String id, ActivitiesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Activity object with the given id. + */ + public CompletableFuture retrieve( + String id, ActivitiesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Activity POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Activity POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/activities/AsyncRawActivitiesClient.java b/src/main/java/com/merge/api/resources/ats/activities/AsyncRawActivitiesClient.java new file mode 100644 index 000000000..1072c3b77 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/activities/AsyncRawActivitiesClient.java @@ -0,0 +1,402 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.activities; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.activities.requests.ActivitiesListRequest; +import com.merge.api.resources.ats.activities.requests.ActivitiesRetrieveRequest; +import com.merge.api.resources.ats.activities.requests.ActivityEndpointRequest; +import com.merge.api.resources.ats.types.Activity; +import com.merge.api.resources.ats.types.ActivityResponse; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedActivityList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawActivitiesClient { + protected final ClientOptions clientOptions; + + public AsyncRawActivitiesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Activity objects. + */ + public CompletableFuture> list() { + return list(ActivitiesListRequest.builder().build()); + } + + /** + * Returns a list of Activity objects. + */ + public CompletableFuture> list(ActivitiesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Activity objects. + */ + public CompletableFuture> list( + ActivitiesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/activities"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedActivityList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Activity object with the given values. + */ + public CompletableFuture> create(ActivityEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Activity object with the given values. + */ + public CompletableFuture> create( + ActivityEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/activities"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ActivityResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Activity object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, ActivitiesRetrieveRequest.builder().build()); + } + + /** + * Returns an Activity object with the given id. + */ + public CompletableFuture> retrieve(String id, ActivitiesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Activity object with the given id. + */ + public CompletableFuture> retrieve( + String id, ActivitiesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/activities") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Activity.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Activity POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Activity POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/activities/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/activities/RawActivitiesClient.java b/src/main/java/com/merge/api/resources/ats/activities/RawActivitiesClient.java new file mode 100644 index 000000000..f42944e39 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/activities/RawActivitiesClient.java @@ -0,0 +1,344 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.activities; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.activities.requests.ActivitiesListRequest; +import com.merge.api.resources.ats.activities.requests.ActivitiesRetrieveRequest; +import com.merge.api.resources.ats.activities.requests.ActivityEndpointRequest; +import com.merge.api.resources.ats.types.Activity; +import com.merge.api.resources.ats.types.ActivityResponse; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedActivityList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawActivitiesClient { + protected final ClientOptions clientOptions; + + public RawActivitiesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Activity objects. + */ + public MergeApiHttpResponse list() { + return list(ActivitiesListRequest.builder().build()); + } + + /** + * Returns a list of Activity objects. + */ + public MergeApiHttpResponse list(ActivitiesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Activity objects. + */ + public MergeApiHttpResponse list( + ActivitiesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/activities"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getUserId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_id", request.getUserId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedActivityList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Activity object with the given values. + */ + public MergeApiHttpResponse create(ActivityEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Activity object with the given values. + */ + public MergeApiHttpResponse create( + ActivityEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/activities"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ActivityResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Activity object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, ActivitiesRetrieveRequest.builder().build()); + } + + /** + * Returns an Activity object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, ActivitiesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Activity object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, ActivitiesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/activities") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Activity.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Activity POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Activity POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/activities/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/activities/requests/ActivitiesListRequest.java b/src/main/java/com/merge/api/resources/ats/activities/requests/ActivitiesListRequest.java index bfbd731b4..9f8ab3e7f 100644 --- a/src/main/java/com/merge/api/resources/ats/activities/requests/ActivitiesListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/activities/requests/ActivitiesListRequest.java @@ -15,7 +15,9 @@ import com.merge.api.resources.ats.activities.types.ActivitiesListRequestRemoteFields; import com.merge.api.resources.ats.activities.types.ActivitiesListRequestShowEnumOrigins; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,14 +25,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ActivitiesListRequest.Builder.class) public final class ActivitiesListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -54,10 +56,10 @@ public final class ActivitiesListRequest { private final Map additionalProperties; private ActivitiesListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -69,10 +71,10 @@ private ActivitiesListRequest( Optional showEnumOrigins, Optional userId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -86,6 +88,14 @@ private ActivitiesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -110,14 +120,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -210,10 +212,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(ActivitiesListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -229,10 +231,10 @@ private boolean equalTo(ActivitiesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -256,14 +258,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -290,10 +292,10 @@ public static final class Builder { private Builder() {} public Builder from(ActivitiesListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -307,6 +309,22 @@ public Builder from(ActivitiesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -340,17 +358,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -463,10 +470,10 @@ public Builder userId(String userId) { public ActivitiesListRequest build() { return new ActivitiesListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/activities/requests/ActivitiesRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/activities/requests/ActivitiesRetrieveRequest.java index 673d7fba5..8de243d1d 100644 --- a/src/main/java/com/merge/api/resources/ats/activities/requests/ActivitiesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/activities/requests/ActivitiesRetrieveRequest.java @@ -14,7 +14,9 @@ import com.merge.api.core.ObjectMappers; import com.merge.api.resources.ats.activities.types.ActivitiesRetrieveRequestRemoteFields; import com.merge.api.resources.ats.activities.types.ActivitiesRetrieveRequestShowEnumOrigins; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,10 +24,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ActivitiesRetrieveRequest.Builder.class) public final class ActivitiesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -33,13 +37,15 @@ public final class ActivitiesRetrieveRequest { private final Map additionalProperties; private ActivitiesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -49,7 +55,7 @@ private ActivitiesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -61,6 +67,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -91,13 +105,15 @@ public Map getAdditionalProperties() { private boolean equalTo(ActivitiesRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -111,10 +127,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -127,22 +145,28 @@ private Builder() {} public Builder from(ActivitiesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -154,6 +178,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -178,7 +213,7 @@ public Builder showEnumOrigins(ActivitiesRetrieveRequestShowEnumOrigins showEnum public ActivitiesRetrieveRequest build() { return new ActivitiesRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/applications/ApplicationsClient.java b/src/main/java/com/merge/api/resources/ats/applications/ApplicationsClient.java index d9399ff64..0bf88985b 100644 --- a/src/main/java/com/merge/api/resources/ats/applications/ApplicationsClient.java +++ b/src/main/java/com/merge/api/resources/ats/applications/ApplicationsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.ats.applications; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.applications.requests.ApplicationEndpointRequest; import com.merge.api.resources.ats.applications.requests.ApplicationsListRequest; @@ -18,131 +14,43 @@ import com.merge.api.resources.ats.types.ApplicationResponse; import com.merge.api.resources.ats.types.MetaResponse; import com.merge.api.resources.ats.types.PaginatedApplicationList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ApplicationsClient { protected final ClientOptions clientOptions; + private final RawApplicationsClient rawClient; + public ApplicationsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawApplicationsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawApplicationsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Application objects. */ public PaginatedApplicationList list() { - return list(ApplicationsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Application objects. */ public PaginatedApplicationList list(ApplicationsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Application objects. */ public PaginatedApplicationList list(ApplicationsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/applications"); - if (request.getCandidateId().isPresent()) { - httpUrl.addQueryParameter("candidate_id", request.getCandidateId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCreditedToId().isPresent()) { - httpUrl.addQueryParameter( - "credited_to_id", request.getCreditedToId().get()); - } - if (request.getCurrentStageId().isPresent()) { - httpUrl.addQueryParameter( - "current_stage_id", request.getCurrentStageId().get()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getJobId().isPresent()) { - httpUrl.addQueryParameter("job_id", request.getJobId().get()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRejectReasonId().isPresent()) { - httpUrl.addQueryParameter( - "reject_reason_id", request.getRejectReasonId().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getSource().isPresent()) { - httpUrl.addQueryParameter("source", request.getSource().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedApplicationList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** @@ -151,7 +59,7 @@ public PaginatedApplicationList list(ApplicationsListRequest request, RequestOpt *

    See our Help Center article for detailed support per integration.

    */ public ApplicationResponse create(ApplicationEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** @@ -160,119 +68,42 @@ public ApplicationResponse create(ApplicationEndpointRequest request) { *

    See our Help Center article for detailed support per integration.

    */ public ApplicationResponse create(ApplicationEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/applications"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - properties.put("remote_user_id", request.getRemoteUserId()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplicationResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Application object with the given id. */ public Application retrieve(String id) { - return retrieve(id, ApplicationsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Application object with the given id. */ public Application retrieve(String id, ApplicationsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Application object with the given id. */ public Application retrieve(String id, ApplicationsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/applications") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Application.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Updates the current_stage field of an Application object */ public ApplicationResponse changeStageCreate(String id) { - return changeStageCreate(id, UpdateApplicationStageRequest.builder().build()); + return this.rawClient.changeStageCreate(id).body(); } /** * Updates the current_stage field of an Application object */ public ApplicationResponse changeStageCreate(String id, UpdateApplicationStageRequest request) { - return changeStageCreate(id, request, null); + return this.rawClient.changeStageCreate(id, request).body(); } /** @@ -280,107 +111,27 @@ public ApplicationResponse changeStageCreate(String id, UpdateApplicationStageRe */ public ApplicationResponse changeStageCreate( String id, UpdateApplicationStageRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/applications") - .addPathSegment(id) - .addPathSegments("change-stage"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - if (request.getJobInterviewStage().isPresent()) { - properties.put("job_interview_stage", request.getJobInterviewStage()); - } - if (request.getRemoteUserId().isPresent()) { - properties.put("remote_user_id", request.getRemoteUserId()); - } - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplicationResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.changeStageCreate(id, request, requestOptions).body(); } /** * Returns metadata for Application POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(ApplicationsMetaPostRetrieveRequest.builder().build()); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Application POSTs. */ public MetaResponse metaPostRetrieve(ApplicationsMetaPostRetrieveRequest request) { - return metaPostRetrieve(request, null); + return this.rawClient.metaPostRetrieve(request).body(); } /** * Returns metadata for Application POSTs. */ public MetaResponse metaPostRetrieve(ApplicationsMetaPostRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/applications/meta/post"); - if (request.getApplicationRemoteTemplateId().isPresent()) { - httpUrl.addQueryParameter( - "application_remote_template_id", - request.getApplicationRemoteTemplateId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/applications/AsyncApplicationsClient.java b/src/main/java/com/merge/api/resources/ats/applications/AsyncApplicationsClient.java new file mode 100644 index 000000000..d3a283e07 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/applications/AsyncApplicationsClient.java @@ -0,0 +1,142 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.applications; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.applications.requests.ApplicationEndpointRequest; +import com.merge.api.resources.ats.applications.requests.ApplicationsListRequest; +import com.merge.api.resources.ats.applications.requests.ApplicationsMetaPostRetrieveRequest; +import com.merge.api.resources.ats.applications.requests.ApplicationsRetrieveRequest; +import com.merge.api.resources.ats.applications.requests.UpdateApplicationStageRequest; +import com.merge.api.resources.ats.types.Application; +import com.merge.api.resources.ats.types.ApplicationResponse; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedApplicationList; +import java.util.concurrent.CompletableFuture; + +public class AsyncApplicationsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawApplicationsClient rawClient; + + public AsyncApplicationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawApplicationsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawApplicationsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Application objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Application objects. + */ + public CompletableFuture list(ApplicationsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Application objects. + */ + public CompletableFuture list( + ApplicationsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Application object with the given values. + * For certain integrations, but not all, our API detects duplicate candidates and will associate applications with existing records in the third-party. New candidates are created and automatically linked to the application. + *

    See our Help Center article for detailed support per integration.

    + */ + public CompletableFuture create(ApplicationEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Application object with the given values. + * For certain integrations, but not all, our API detects duplicate candidates and will associate applications with existing records in the third-party. New candidates are created and automatically linked to the application. + *

    See our Help Center article for detailed support per integration.

    + */ + public CompletableFuture create( + ApplicationEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Application object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Application object with the given id. + */ + public CompletableFuture retrieve(String id, ApplicationsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Application object with the given id. + */ + public CompletableFuture retrieve( + String id, ApplicationsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates the current_stage field of an Application object + */ + public CompletableFuture changeStageCreate(String id) { + return this.rawClient.changeStageCreate(id).thenApply(response -> response.body()); + } + + /** + * Updates the current_stage field of an Application object + */ + public CompletableFuture changeStageCreate(String id, UpdateApplicationStageRequest request) { + return this.rawClient.changeStageCreate(id, request).thenApply(response -> response.body()); + } + + /** + * Updates the current_stage field of an Application object + */ + public CompletableFuture changeStageCreate( + String id, UpdateApplicationStageRequest request, RequestOptions requestOptions) { + return this.rawClient.changeStageCreate(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Application POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Application POSTs. + */ + public CompletableFuture metaPostRetrieve(ApplicationsMetaPostRetrieveRequest request) { + return this.rawClient.metaPostRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Application POSTs. + */ + public CompletableFuture metaPostRetrieve( + ApplicationsMetaPostRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/applications/AsyncRawApplicationsClient.java b/src/main/java/com/merge/api/resources/ats/applications/AsyncRawApplicationsClient.java new file mode 100644 index 000000000..1e8d05e00 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/applications/AsyncRawApplicationsClient.java @@ -0,0 +1,513 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.applications; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.applications.requests.ApplicationEndpointRequest; +import com.merge.api.resources.ats.applications.requests.ApplicationsListRequest; +import com.merge.api.resources.ats.applications.requests.ApplicationsMetaPostRetrieveRequest; +import com.merge.api.resources.ats.applications.requests.ApplicationsRetrieveRequest; +import com.merge.api.resources.ats.applications.requests.UpdateApplicationStageRequest; +import com.merge.api.resources.ats.types.Application; +import com.merge.api.resources.ats.types.ApplicationResponse; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedApplicationList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawApplicationsClient { + protected final ClientOptions clientOptions; + + public AsyncRawApplicationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Application objects. + */ + public CompletableFuture> list() { + return list(ApplicationsListRequest.builder().build()); + } + + /** + * Returns a list of Application objects. + */ + public CompletableFuture> list(ApplicationsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Application objects. + */ + public CompletableFuture> list( + ApplicationsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/applications"); + if (request.getCandidateId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "candidate_id", request.getCandidateId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCreditedToId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credited_to_id", request.getCreditedToId().get(), false); + } + if (request.getCurrentStageId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "current_stage_id", request.getCurrentStageId().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getJobId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "job_id", request.getJobId().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRejectReasonId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "reject_reason_id", request.getRejectReasonId().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getSource().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "source", request.getSource().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedApplicationList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Application object with the given values. + * For certain integrations, but not all, our API detects duplicate candidates and will associate applications with existing records in the third-party. New candidates are created and automatically linked to the application. + *

    See our Help Center article for detailed support per integration.

    + */ + public CompletableFuture> create(ApplicationEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Application object with the given values. + * For certain integrations, but not all, our API detects duplicate candidates and will associate applications with existing records in the third-party. New candidates are created and automatically linked to the application. + *

    See our Help Center article for detailed support per integration.

    + */ + public CompletableFuture> create( + ApplicationEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/applications"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplicationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Application object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, ApplicationsRetrieveRequest.builder().build()); + } + + /** + * Returns an Application object with the given id. + */ + public CompletableFuture> retrieve( + String id, ApplicationsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Application object with the given id. + */ + public CompletableFuture> retrieve( + String id, ApplicationsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/applications") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Application.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Updates the current_stage field of an Application object + */ + public CompletableFuture> changeStageCreate(String id) { + return changeStageCreate(id, UpdateApplicationStageRequest.builder().build()); + } + + /** + * Updates the current_stage field of an Application object + */ + public CompletableFuture> changeStageCreate( + String id, UpdateApplicationStageRequest request) { + return changeStageCreate(id, request, null); + } + + /** + * Updates the current_stage field of an Application object + */ + public CompletableFuture> changeStageCreate( + String id, UpdateApplicationStageRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/applications") + .addPathSegment(id) + .addPathSegments("change-stage"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + if (request.getJobInterviewStage().isPresent()) { + properties.put("job_interview_stage", request.getJobInterviewStage()); + } + if (request.getRemoteUserId().isPresent()) { + properties.put("remote_user_id", request.getRemoteUserId()); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplicationResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Application POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(ApplicationsMetaPostRetrieveRequest.builder().build()); + } + + /** + * Returns metadata for Application POSTs. + */ + public CompletableFuture> metaPostRetrieve( + ApplicationsMetaPostRetrieveRequest request) { + return metaPostRetrieve(request, null); + } + + /** + * Returns metadata for Application POSTs. + */ + public CompletableFuture> metaPostRetrieve( + ApplicationsMetaPostRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/applications/meta/post"); + if (request.getApplicationRemoteTemplateId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "application_remote_template_id", + request.getApplicationRemoteTemplateId().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/applications/RawApplicationsClient.java b/src/main/java/com/merge/api/resources/ats/applications/RawApplicationsClient.java new file mode 100644 index 000000000..87a09f99f --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/applications/RawApplicationsClient.java @@ -0,0 +1,439 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.applications; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.applications.requests.ApplicationEndpointRequest; +import com.merge.api.resources.ats.applications.requests.ApplicationsListRequest; +import com.merge.api.resources.ats.applications.requests.ApplicationsMetaPostRetrieveRequest; +import com.merge.api.resources.ats.applications.requests.ApplicationsRetrieveRequest; +import com.merge.api.resources.ats.applications.requests.UpdateApplicationStageRequest; +import com.merge.api.resources.ats.types.Application; +import com.merge.api.resources.ats.types.ApplicationResponse; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedApplicationList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawApplicationsClient { + protected final ClientOptions clientOptions; + + public RawApplicationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Application objects. + */ + public MergeApiHttpResponse list() { + return list(ApplicationsListRequest.builder().build()); + } + + /** + * Returns a list of Application objects. + */ + public MergeApiHttpResponse list(ApplicationsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Application objects. + */ + public MergeApiHttpResponse list( + ApplicationsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/applications"); + if (request.getCandidateId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "candidate_id", request.getCandidateId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCreditedToId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "credited_to_id", request.getCreditedToId().get(), false); + } + if (request.getCurrentStageId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "current_stage_id", request.getCurrentStageId().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getJobId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "job_id", request.getJobId().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRejectReasonId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "reject_reason_id", request.getRejectReasonId().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getSource().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "source", request.getSource().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedApplicationList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Application object with the given values. + * For certain integrations, but not all, our API detects duplicate candidates and will associate applications with existing records in the third-party. New candidates are created and automatically linked to the application. + *

    See our Help Center article for detailed support per integration.

    + */ + public MergeApiHttpResponse create(ApplicationEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Application object with the given values. + * For certain integrations, but not all, our API detects duplicate candidates and will associate applications with existing records in the third-party. New candidates are created and automatically linked to the application. + *

    See our Help Center article for detailed support per integration.

    + */ + public MergeApiHttpResponse create( + ApplicationEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/applications"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplicationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Application object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, ApplicationsRetrieveRequest.builder().build()); + } + + /** + * Returns an Application object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, ApplicationsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Application object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, ApplicationsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/applications") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Application.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Updates the current_stage field of an Application object + */ + public MergeApiHttpResponse changeStageCreate(String id) { + return changeStageCreate(id, UpdateApplicationStageRequest.builder().build()); + } + + /** + * Updates the current_stage field of an Application object + */ + public MergeApiHttpResponse changeStageCreate( + String id, UpdateApplicationStageRequest request) { + return changeStageCreate(id, request, null); + } + + /** + * Updates the current_stage field of an Application object + */ + public MergeApiHttpResponse changeStageCreate( + String id, UpdateApplicationStageRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/applications") + .addPathSegment(id) + .addPathSegments("change-stage"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + if (request.getJobInterviewStage().isPresent()) { + properties.put("job_interview_stage", request.getJobInterviewStage()); + } + if (request.getRemoteUserId().isPresent()) { + properties.put("remote_user_id", request.getRemoteUserId()); + } + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ApplicationResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Application POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(ApplicationsMetaPostRetrieveRequest.builder().build()); + } + + /** + * Returns metadata for Application POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(ApplicationsMetaPostRetrieveRequest request) { + return metaPostRetrieve(request, null); + } + + /** + * Returns metadata for Application POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve( + ApplicationsMetaPostRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/applications/meta/post"); + if (request.getApplicationRemoteTemplateId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "application_remote_template_id", + request.getApplicationRemoteTemplateId().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/applications/requests/ApplicationsListRequest.java b/src/main/java/com/merge/api/resources/ats/applications/requests/ApplicationsListRequest.java index f7c6b0975..b5f1c617a 100644 --- a/src/main/java/com/merge/api/resources/ats/applications/requests/ApplicationsListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/applications/requests/ApplicationsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.applications.types.ApplicationsListRequestExpand; +import com.merge.api.resources.ats.applications.types.ApplicationsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ApplicationsListRequest.Builder.class) public final class ApplicationsListRequest { + private final Optional> expand; + private final Optional candidateId; private final Optional createdAfter; @@ -34,8 +38,6 @@ public final class ApplicationsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -59,13 +61,13 @@ public final class ApplicationsListRequest { private final Map additionalProperties; private ApplicationsListRequest( + Optional> expand, Optional candidateId, Optional createdAfter, Optional createdBefore, Optional creditedToId, Optional currentStageId, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -77,13 +79,13 @@ private ApplicationsListRequest( Optional remoteId, Optional source, Map additionalProperties) { + this.expand = expand; this.candidateId = candidateId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.creditedToId = creditedToId; this.currentStageId = currentStageId; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -97,6 +99,14 @@ private ApplicationsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return applications for this candidate. */ @@ -145,14 +155,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -245,13 +247,13 @@ public Map getAdditionalProperties() { } private boolean equalTo(ApplicationsListRequest other) { - return candidateId.equals(other.candidateId) + return expand.equals(other.expand) + && candidateId.equals(other.candidateId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && creditedToId.equals(other.creditedToId) && currentStageId.equals(other.currentStageId) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -267,13 +269,13 @@ private boolean equalTo(ApplicationsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.candidateId, this.createdAfter, this.createdBefore, this.creditedToId, this.currentStageId, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -297,6 +299,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional candidateId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -309,8 +313,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -337,13 +339,13 @@ public static final class Builder { private Builder() {} public Builder from(ApplicationsListRequest other) { + expand(other.getExpand()); candidateId(other.getCandidateId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); creditedToId(other.getCreditedToId()); currentStageId(other.getCurrentStageId()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -357,6 +359,22 @@ public Builder from(ApplicationsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(ApplicationsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "candidate_id", nulls = Nulls.SKIP) public Builder candidateId(Optional candidateId) { this.candidateId = candidateId; @@ -423,17 +441,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(ApplicationsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -546,13 +553,13 @@ public Builder source(String source) { public ApplicationsListRequest build() { return new ApplicationsListRequest( + expand, candidateId, createdAfter, createdBefore, creditedToId, currentStageId, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/applications/requests/ApplicationsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/applications/requests/ApplicationsRetrieveRequest.java index 835565218..2dfc453d3 100644 --- a/src/main/java/com/merge/api/resources/ats/applications/requests/ApplicationsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/applications/requests/ApplicationsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.applications.types.ApplicationsRetrieveRequestExpand; +import com.merge.api.resources.ats.applications.types.ApplicationsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ApplicationsRetrieveRequest.Builder.class) public final class ApplicationsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private ApplicationsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private ApplicationsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(ApplicationsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -83,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,20 +113,26 @@ private Builder() {} public Builder from(ApplicationsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(ApplicationsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(ApplicationsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -120,8 +144,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public ApplicationsRetrieveRequest build() { - return new ApplicationsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new ApplicationsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsListRequestExpand.java b/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsListRequestExpand.java deleted file mode 100644 index 8c8e1e8fe..000000000 --- a/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsListRequestExpand.java +++ /dev/null @@ -1,680 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.applications.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ApplicationsListRequestExpand { - CANDIDATE("candidate"), - - CANDIDATE_CREDITED_TO("candidate,credited_to"), - - CANDIDATE_CREDITED_TO_CURRENT_STAGE("candidate,credited_to,current_stage"), - - CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON("candidate,credited_to,current_stage,reject_reason"), - - CANDIDATE_CREDITED_TO_REJECT_REASON("candidate,credited_to,reject_reason"), - - CANDIDATE_CURRENT_STAGE("candidate,current_stage"), - - CANDIDATE_CURRENT_STAGE_REJECT_REASON("candidate,current_stage,reject_reason"), - - CANDIDATE_JOB("candidate,job"), - - CANDIDATE_JOB_CREDITED_TO("candidate,job,credited_to"), - - CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE("candidate,job,credited_to,current_stage"), - - CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON("candidate,job,credited_to,current_stage,reject_reason"), - - CANDIDATE_JOB_CREDITED_TO_REJECT_REASON("candidate,job,credited_to,reject_reason"), - - CANDIDATE_JOB_CURRENT_STAGE("candidate,job,current_stage"), - - CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON("candidate,job,current_stage,reject_reason"), - - CANDIDATE_JOB_REJECT_REASON("candidate,job,reject_reason"), - - CANDIDATE_REJECT_REASON("candidate,reject_reason"), - - CREDITED_TO("credited_to"), - - CREDITED_TO_CURRENT_STAGE("credited_to,current_stage"), - - CREDITED_TO_CURRENT_STAGE_REJECT_REASON("credited_to,current_stage,reject_reason"), - - CREDITED_TO_REJECT_REASON("credited_to,reject_reason"), - - CURRENT_STAGE("current_stage"), - - CURRENT_STAGE_REJECT_REASON("current_stage,reject_reason"), - - JOB("job"), - - JOB_CREDITED_TO("job,credited_to"), - - JOB_CREDITED_TO_CURRENT_STAGE("job,credited_to,current_stage"), - - JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON("job,credited_to,current_stage,reject_reason"), - - JOB_CREDITED_TO_REJECT_REASON("job,credited_to,reject_reason"), - - JOB_CURRENT_STAGE("job,current_stage"), - - JOB_CURRENT_STAGE_REJECT_REASON("job,current_stage,reject_reason"), - - JOB_REJECT_REASON("job,reject_reason"), - - OFFERS("offers"), - - OFFERS_CANDIDATE("offers,candidate"), - - OFFERS_CANDIDATE_CREDITED_TO("offers,candidate,credited_to"), - - OFFERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE("offers,candidate,credited_to,current_stage"), - - OFFERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,candidate,credited_to,current_stage,reject_reason"), - - OFFERS_CANDIDATE_CREDITED_TO_REJECT_REASON("offers,candidate,credited_to,reject_reason"), - - OFFERS_CANDIDATE_CURRENT_STAGE("offers,candidate,current_stage"), - - OFFERS_CANDIDATE_CURRENT_STAGE_REJECT_REASON("offers,candidate,current_stage,reject_reason"), - - OFFERS_CANDIDATE_JOB("offers,candidate,job"), - - OFFERS_CANDIDATE_JOB_CREDITED_TO("offers,candidate,job,credited_to"), - - OFFERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE("offers,candidate,job,credited_to,current_stage"), - - OFFERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,candidate,job,credited_to,current_stage,reject_reason"), - - OFFERS_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON("offers,candidate,job,credited_to,reject_reason"), - - OFFERS_CANDIDATE_JOB_CURRENT_STAGE("offers,candidate,job,current_stage"), - - OFFERS_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON("offers,candidate,job,current_stage,reject_reason"), - - OFFERS_CANDIDATE_JOB_REJECT_REASON("offers,candidate,job,reject_reason"), - - OFFERS_CANDIDATE_REJECT_REASON("offers,candidate,reject_reason"), - - OFFERS_CREDITED_TO("offers,credited_to"), - - OFFERS_CREDITED_TO_CURRENT_STAGE("offers,credited_to,current_stage"), - - OFFERS_CREDITED_TO_CURRENT_STAGE_REJECT_REASON("offers,credited_to,current_stage,reject_reason"), - - OFFERS_CREDITED_TO_REJECT_REASON("offers,credited_to,reject_reason"), - - OFFERS_CURRENT_STAGE("offers,current_stage"), - - OFFERS_CURRENT_STAGE_REJECT_REASON("offers,current_stage,reject_reason"), - - OFFERS_JOB("offers,job"), - - OFFERS_JOB_CREDITED_TO("offers,job,credited_to"), - - OFFERS_JOB_CREDITED_TO_CURRENT_STAGE("offers,job,credited_to,current_stage"), - - OFFERS_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON("offers,job,credited_to,current_stage,reject_reason"), - - OFFERS_JOB_CREDITED_TO_REJECT_REASON("offers,job,credited_to,reject_reason"), - - OFFERS_JOB_CURRENT_STAGE("offers,job,current_stage"), - - OFFERS_JOB_CURRENT_STAGE_REJECT_REASON("offers,job,current_stage,reject_reason"), - - OFFERS_JOB_REJECT_REASON("offers,job,reject_reason"), - - OFFERS_REJECT_REASON("offers,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS("offers,screening_question_answers"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE("offers,screening_question_answers,candidate"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO("offers,screening_question_answers,candidate,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,candidate,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,candidate,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,candidate,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CURRENT_STAGE( - "offers,screening_question_answers,candidate,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,candidate,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB("offers,screening_question_answers,candidate,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO( - "offers,screening_question_answers,candidate,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,candidate,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,candidate,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,candidate,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CURRENT_STAGE( - "offers,screening_question_answers,candidate,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,candidate,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_REJECT_REASON( - "offers,screening_question_answers,candidate,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_REJECT_REASON( - "offers,screening_question_answers,candidate,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CREDITED_TO("offers,screening_question_answers,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CURRENT_STAGE("offers,screening_question_answers,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB("offers,screening_question_answers,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO("offers,screening_question_answers,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CURRENT_STAGE("offers,screening_question_answers,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_REJECT_REASON("offers,screening_question_answers,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_REJECT_REASON("offers,screening_question_answers,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION( - "offers,screening_question_answers,screening_question_answers.question"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE( - "offers,screening_question_answers,screening_question_answers.question,candidate"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO( - "offers,screening_question_answers,screening_question_answers.question,candidate,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,candidate,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,candidate,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB( - "offers,screening_question_answers,screening_question_answers.question,candidate,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO( - "offers,screening_question_answers,screening_question_answers.question,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB( - "offers,screening_question_answers,screening_question_answers.question,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO( - "offers,screening_question_answers,screening_question_answers.question,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION("offers,screening_question_answers.question"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE("offers,screening_question_answers.question,candidate"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO( - "offers,screening_question_answers.question,candidate,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers.question,candidate,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,candidate,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers.question,candidate,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE( - "offers,screening_question_answers.question,candidate,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,candidate,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB( - "offers,screening_question_answers.question,candidate,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO( - "offers,screening_question_answers.question,candidate,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers.question,candidate,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,candidate,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers.question,candidate,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE( - "offers,screening_question_answers.question,candidate,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,candidate,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_REJECT_REASON( - "offers,screening_question_answers.question,candidate,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_REJECT_REASON( - "offers,screening_question_answers.question,candidate,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO("offers,screening_question_answers.question,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers.question,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers.question,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE( - "offers,screening_question_answers.question,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB("offers,screening_question_answers.question,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO( - "offers,screening_question_answers.question,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers.question,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers.question,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE( - "offers,screening_question_answers.question,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_REJECT_REASON( - "offers,screening_question_answers.question,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_REJECT_REASON( - "offers,screening_question_answers.question,reject_reason"), - - REJECT_REASON("reject_reason"), - - SCREENING_QUESTION_ANSWERS("screening_question_answers"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE("screening_question_answers,candidate"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO("screening_question_answers,candidate,credited_to"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,candidate,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,candidate,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_REJECT_REASON( - "screening_question_answers,candidate,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CURRENT_STAGE("screening_question_answers,candidate,current_stage"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,candidate,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB("screening_question_answers,candidate,job"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO("screening_question_answers,candidate,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,candidate,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,candidate,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers,candidate,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CURRENT_STAGE("screening_question_answers,candidate,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,candidate,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_REJECT_REASON("screening_question_answers,candidate,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_REJECT_REASON("screening_question_answers,candidate,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CREDITED_TO("screening_question_answers,credited_to"), - - SCREENING_QUESTION_ANSWERS_CREDITED_TO_CURRENT_STAGE("screening_question_answers,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CREDITED_TO_REJECT_REASON("screening_question_answers,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CURRENT_STAGE("screening_question_answers,current_stage"), - - SCREENING_QUESTION_ANSWERS_CURRENT_STAGE_REJECT_REASON("screening_question_answers,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_JOB("screening_question_answers,job"), - - SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO("screening_question_answers,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_JOB_CURRENT_STAGE("screening_question_answers,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_JOB_REJECT_REASON("screening_question_answers,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_REJECT_REASON("screening_question_answers,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION( - "screening_question_answers,screening_question_answers.question"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE( - "screening_question_answers,screening_question_answers.question,candidate"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO( - "screening_question_answers,screening_question_answers.question,candidate,credited_to"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,candidate,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,candidate,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB( - "screening_question_answers,screening_question_answers.question,candidate,job"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO( - "screening_question_answers,screening_question_answers.question,candidate,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,candidate,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,candidate,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO( - "screening_question_answers,screening_question_answers.question,credited_to"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB( - "screening_question_answers,screening_question_answers.question,job"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO( - "screening_question_answers,screening_question_answers.question,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION("screening_question_answers.question"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE("screening_question_answers.question,candidate"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO( - "screening_question_answers.question,candidate,credited_to"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers.question,candidate,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,candidate,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_REJECT_REASON( - "screening_question_answers.question,candidate,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE( - "screening_question_answers.question,candidate,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,candidate,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB("screening_question_answers.question,candidate,job"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO( - "screening_question_answers.question,candidate,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers.question,candidate,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,candidate,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers.question,candidate,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE( - "screening_question_answers.question,candidate,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,candidate,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_REJECT_REASON( - "screening_question_answers.question,candidate,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_REJECT_REASON( - "screening_question_answers.question,candidate,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO("screening_question_answers.question,credited_to"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers.question,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_REJECT_REASON( - "screening_question_answers.question,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE("screening_question_answers.question,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB("screening_question_answers.question,job"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO("screening_question_answers.question,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers.question,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers.question,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE("screening_question_answers.question,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_REJECT_REASON("screening_question_answers.question,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_REJECT_REASON("screening_question_answers.question,reject_reason"); - - private final String value; - - ApplicationsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsListRequestExpandItem.java new file mode 100644 index 000000000..569361fdb --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsListRequestExpandItem.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.applications.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ApplicationsListRequestExpandItem { + CANDIDATE("candidate"), + + CREDITED_TO("credited_to"), + + CURRENT_STAGE("current_stage"), + + JOB("job"), + + OFFERS("offers"), + + REJECT_REASON("reject_reason"), + + SCREENING_QUESTION_ANSWERS("screening_question_answers"), + + SCREENING_QUESTION_ANSWERS_QUESTION("screening_question_answers.question"); + + private final String value; + + ApplicationsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsRetrieveRequestExpand.java deleted file mode 100644 index 6a71bb5f0..000000000 --- a/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsRetrieveRequestExpand.java +++ /dev/null @@ -1,680 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.applications.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ApplicationsRetrieveRequestExpand { - CANDIDATE("candidate"), - - CANDIDATE_CREDITED_TO("candidate,credited_to"), - - CANDIDATE_CREDITED_TO_CURRENT_STAGE("candidate,credited_to,current_stage"), - - CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON("candidate,credited_to,current_stage,reject_reason"), - - CANDIDATE_CREDITED_TO_REJECT_REASON("candidate,credited_to,reject_reason"), - - CANDIDATE_CURRENT_STAGE("candidate,current_stage"), - - CANDIDATE_CURRENT_STAGE_REJECT_REASON("candidate,current_stage,reject_reason"), - - CANDIDATE_JOB("candidate,job"), - - CANDIDATE_JOB_CREDITED_TO("candidate,job,credited_to"), - - CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE("candidate,job,credited_to,current_stage"), - - CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON("candidate,job,credited_to,current_stage,reject_reason"), - - CANDIDATE_JOB_CREDITED_TO_REJECT_REASON("candidate,job,credited_to,reject_reason"), - - CANDIDATE_JOB_CURRENT_STAGE("candidate,job,current_stage"), - - CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON("candidate,job,current_stage,reject_reason"), - - CANDIDATE_JOB_REJECT_REASON("candidate,job,reject_reason"), - - CANDIDATE_REJECT_REASON("candidate,reject_reason"), - - CREDITED_TO("credited_to"), - - CREDITED_TO_CURRENT_STAGE("credited_to,current_stage"), - - CREDITED_TO_CURRENT_STAGE_REJECT_REASON("credited_to,current_stage,reject_reason"), - - CREDITED_TO_REJECT_REASON("credited_to,reject_reason"), - - CURRENT_STAGE("current_stage"), - - CURRENT_STAGE_REJECT_REASON("current_stage,reject_reason"), - - JOB("job"), - - JOB_CREDITED_TO("job,credited_to"), - - JOB_CREDITED_TO_CURRENT_STAGE("job,credited_to,current_stage"), - - JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON("job,credited_to,current_stage,reject_reason"), - - JOB_CREDITED_TO_REJECT_REASON("job,credited_to,reject_reason"), - - JOB_CURRENT_STAGE("job,current_stage"), - - JOB_CURRENT_STAGE_REJECT_REASON("job,current_stage,reject_reason"), - - JOB_REJECT_REASON("job,reject_reason"), - - OFFERS("offers"), - - OFFERS_CANDIDATE("offers,candidate"), - - OFFERS_CANDIDATE_CREDITED_TO("offers,candidate,credited_to"), - - OFFERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE("offers,candidate,credited_to,current_stage"), - - OFFERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,candidate,credited_to,current_stage,reject_reason"), - - OFFERS_CANDIDATE_CREDITED_TO_REJECT_REASON("offers,candidate,credited_to,reject_reason"), - - OFFERS_CANDIDATE_CURRENT_STAGE("offers,candidate,current_stage"), - - OFFERS_CANDIDATE_CURRENT_STAGE_REJECT_REASON("offers,candidate,current_stage,reject_reason"), - - OFFERS_CANDIDATE_JOB("offers,candidate,job"), - - OFFERS_CANDIDATE_JOB_CREDITED_TO("offers,candidate,job,credited_to"), - - OFFERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE("offers,candidate,job,credited_to,current_stage"), - - OFFERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,candidate,job,credited_to,current_stage,reject_reason"), - - OFFERS_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON("offers,candidate,job,credited_to,reject_reason"), - - OFFERS_CANDIDATE_JOB_CURRENT_STAGE("offers,candidate,job,current_stage"), - - OFFERS_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON("offers,candidate,job,current_stage,reject_reason"), - - OFFERS_CANDIDATE_JOB_REJECT_REASON("offers,candidate,job,reject_reason"), - - OFFERS_CANDIDATE_REJECT_REASON("offers,candidate,reject_reason"), - - OFFERS_CREDITED_TO("offers,credited_to"), - - OFFERS_CREDITED_TO_CURRENT_STAGE("offers,credited_to,current_stage"), - - OFFERS_CREDITED_TO_CURRENT_STAGE_REJECT_REASON("offers,credited_to,current_stage,reject_reason"), - - OFFERS_CREDITED_TO_REJECT_REASON("offers,credited_to,reject_reason"), - - OFFERS_CURRENT_STAGE("offers,current_stage"), - - OFFERS_CURRENT_STAGE_REJECT_REASON("offers,current_stage,reject_reason"), - - OFFERS_JOB("offers,job"), - - OFFERS_JOB_CREDITED_TO("offers,job,credited_to"), - - OFFERS_JOB_CREDITED_TO_CURRENT_STAGE("offers,job,credited_to,current_stage"), - - OFFERS_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON("offers,job,credited_to,current_stage,reject_reason"), - - OFFERS_JOB_CREDITED_TO_REJECT_REASON("offers,job,credited_to,reject_reason"), - - OFFERS_JOB_CURRENT_STAGE("offers,job,current_stage"), - - OFFERS_JOB_CURRENT_STAGE_REJECT_REASON("offers,job,current_stage,reject_reason"), - - OFFERS_JOB_REJECT_REASON("offers,job,reject_reason"), - - OFFERS_REJECT_REASON("offers,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS("offers,screening_question_answers"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE("offers,screening_question_answers,candidate"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO("offers,screening_question_answers,candidate,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,candidate,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,candidate,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,candidate,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CURRENT_STAGE( - "offers,screening_question_answers,candidate,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,candidate,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB("offers,screening_question_answers,candidate,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO( - "offers,screening_question_answers,candidate,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,candidate,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,candidate,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,candidate,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CURRENT_STAGE( - "offers,screening_question_answers,candidate,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,candidate,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_REJECT_REASON( - "offers,screening_question_answers,candidate,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CANDIDATE_REJECT_REASON( - "offers,screening_question_answers,candidate,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CREDITED_TO("offers,screening_question_answers,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CURRENT_STAGE("offers,screening_question_answers,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB("offers,screening_question_answers,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO("offers,screening_question_answers,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CURRENT_STAGE("offers,screening_question_answers,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_JOB_REJECT_REASON("offers,screening_question_answers,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_REJECT_REASON("offers,screening_question_answers,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION( - "offers,screening_question_answers,screening_question_answers.question"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE( - "offers,screening_question_answers,screening_question_answers.question,candidate"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO( - "offers,screening_question_answers,screening_question_answers.question,candidate,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,candidate,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,candidate,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB( - "offers,screening_question_answers,screening_question_answers.question,candidate,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,candidate,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO( - "offers,screening_question_answers,screening_question_answers.question,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB( - "offers,screening_question_answers,screening_question_answers.question,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO( - "offers,screening_question_answers,screening_question_answers.question,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE( - "offers,screening_question_answers,screening_question_answers.question,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_REJECT_REASON( - "offers,screening_question_answers,screening_question_answers.question,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION("offers,screening_question_answers.question"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE("offers,screening_question_answers.question,candidate"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO( - "offers,screening_question_answers.question,candidate,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers.question,candidate,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,candidate,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers.question,candidate,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE( - "offers,screening_question_answers.question,candidate,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,candidate,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB( - "offers,screening_question_answers.question,candidate,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO( - "offers,screening_question_answers.question,candidate,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers.question,candidate,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,candidate,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers.question,candidate,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE( - "offers,screening_question_answers.question,candidate,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,candidate,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_REJECT_REASON( - "offers,screening_question_answers.question,candidate,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_REJECT_REASON( - "offers,screening_question_answers.question,candidate,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO("offers,screening_question_answers.question,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers.question,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers.question,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE( - "offers,screening_question_answers.question,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB("offers,screening_question_answers.question,job"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO( - "offers,screening_question_answers.question,job,credited_to"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE( - "offers,screening_question_answers.question,job,credited_to,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,job,credited_to,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_REJECT_REASON( - "offers,screening_question_answers.question,job,credited_to,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE( - "offers,screening_question_answers.question,job,current_stage"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE_REJECT_REASON( - "offers,screening_question_answers.question,job,current_stage,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_REJECT_REASON( - "offers,screening_question_answers.question,job,reject_reason"), - - OFFERS_SCREENING_QUESTION_ANSWERS_QUESTION_REJECT_REASON( - "offers,screening_question_answers.question,reject_reason"), - - REJECT_REASON("reject_reason"), - - SCREENING_QUESTION_ANSWERS("screening_question_answers"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE("screening_question_answers,candidate"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO("screening_question_answers,candidate,credited_to"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,candidate,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,candidate,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CREDITED_TO_REJECT_REASON( - "screening_question_answers,candidate,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CURRENT_STAGE("screening_question_answers,candidate,current_stage"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,candidate,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB("screening_question_answers,candidate,job"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO("screening_question_answers,candidate,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,candidate,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,candidate,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers,candidate,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CURRENT_STAGE("screening_question_answers,candidate,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,candidate,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_JOB_REJECT_REASON("screening_question_answers,candidate,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CANDIDATE_REJECT_REASON("screening_question_answers,candidate,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CREDITED_TO("screening_question_answers,credited_to"), - - SCREENING_QUESTION_ANSWERS_CREDITED_TO_CURRENT_STAGE("screening_question_answers,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CREDITED_TO_REJECT_REASON("screening_question_answers,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_CURRENT_STAGE("screening_question_answers,current_stage"), - - SCREENING_QUESTION_ANSWERS_CURRENT_STAGE_REJECT_REASON("screening_question_answers,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_JOB("screening_question_answers,job"), - - SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO("screening_question_answers,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_JOB_CURRENT_STAGE("screening_question_answers,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_JOB_REJECT_REASON("screening_question_answers,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_REJECT_REASON("screening_question_answers,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION( - "screening_question_answers,screening_question_answers.question"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE( - "screening_question_answers,screening_question_answers.question,candidate"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO( - "screening_question_answers,screening_question_answers.question,candidate,credited_to"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,candidate,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,candidate,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB( - "screening_question_answers,screening_question_answers.question,candidate,job"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO( - "screening_question_answers,screening_question_answers.question,candidate,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,candidate,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,candidate,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,candidate,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO( - "screening_question_answers,screening_question_answers.question,credited_to"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB( - "screening_question_answers,screening_question_answers.question,job"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO( - "screening_question_answers,screening_question_answers.question,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE( - "screening_question_answers,screening_question_answers.question,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_JOB_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_SCREENING_QUESTION_ANSWERS_QUESTION_REJECT_REASON( - "screening_question_answers,screening_question_answers.question,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION("screening_question_answers.question"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE("screening_question_answers.question,candidate"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO( - "screening_question_answers.question,candidate,credited_to"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers.question,candidate,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,candidate,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CREDITED_TO_REJECT_REASON( - "screening_question_answers.question,candidate,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE( - "screening_question_answers.question,candidate,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,candidate,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB("screening_question_answers.question,candidate,job"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO( - "screening_question_answers.question,candidate,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers.question,candidate,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,candidate,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers.question,candidate,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE( - "screening_question_answers.question,candidate,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,candidate,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_JOB_REJECT_REASON( - "screening_question_answers.question,candidate,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CANDIDATE_REJECT_REASON( - "screening_question_answers.question,candidate,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO("screening_question_answers.question,credited_to"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers.question,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CREDITED_TO_REJECT_REASON( - "screening_question_answers.question,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE("screening_question_answers.question,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB("screening_question_answers.question,job"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO("screening_question_answers.question,job,credited_to"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE( - "screening_question_answers.question,job,credited_to,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,job,credited_to,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CREDITED_TO_REJECT_REASON( - "screening_question_answers.question,job,credited_to,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE("screening_question_answers.question,job,current_stage"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_CURRENT_STAGE_REJECT_REASON( - "screening_question_answers.question,job,current_stage,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_JOB_REJECT_REASON("screening_question_answers.question,job,reject_reason"), - - SCREENING_QUESTION_ANSWERS_QUESTION_REJECT_REASON("screening_question_answers.question,reject_reason"); - - private final String value; - - ApplicationsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..87fb8cd17 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/applications/types/ApplicationsRetrieveRequestExpandItem.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.applications.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ApplicationsRetrieveRequestExpandItem { + CANDIDATE("candidate"), + + CREDITED_TO("credited_to"), + + CURRENT_STAGE("current_stage"), + + JOB("job"), + + OFFERS("offers"), + + REJECT_REASON("reject_reason"), + + SCREENING_QUESTION_ANSWERS("screening_question_answers"), + + SCREENING_QUESTION_ANSWERS_QUESTION("screening_question_answers.question"); + + private final String value; + + ApplicationsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncAsyncPassthroughClient.java new file mode 100644 index 000000000..e4020c4c3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncAsyncPassthroughClient.java @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.asyncpassthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.ats.types.AsyncPassthroughReciept; +import com.merge.api.resources.ats.types.DataPassthroughRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAsyncPassthroughClient rawClient; + + public AsyncAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAsyncPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create( + DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve(String asyncPassthroughReceiptId) { + return this.rawClient.retrieve(asyncPassthroughReceiptId).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncPassthroughClient.java index 30fb918fc..d2780a9a4 100644 --- a/src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncPassthroughClient.java +++ b/src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncPassthroughClient.java @@ -3,119 +3,56 @@ */ package com.merge.api.resources.ats.asyncpassthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; import com.merge.api.resources.ats.types.AsyncPassthroughReciept; import com.merge.api.resources.ats.types.DataPassthroughRequest; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AsyncPassthroughClient { protected final ClientOptions clientOptions; + private final RawAsyncPassthroughClient rawClient; + public AsyncPassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAsyncPassthroughClient withRawResponse() { + return this.rawClient; } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/async-passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId) { - return retrieve(asyncPassthroughReceiptId, null); + return this.rawClient.retrieve(asyncPassthroughReceiptId).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/async-passthrough") - .addPathSegment(asyncPassthroughReceiptId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), AsyncPassthroughRetrieveResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncRawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncRawAsyncPassthroughClient.java new file mode 100644 index 000000000..f582095e2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncRawAsyncPassthroughClient.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.ats.types.AsyncPassthroughReciept; +import com.merge.api.resources.ats.types.DataPassthroughRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughReciept.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/asyncpassthrough/RawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/ats/asyncpassthrough/RawAsyncPassthroughClient.java new file mode 100644 index 000000000..11b1db19f --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/asyncpassthrough/RawAsyncPassthroughClient.java @@ -0,0 +1,131 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.ats.types.AsyncPassthroughReciept; +import com.merge.api.resources.ats.types.DataPassthroughRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public RawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve(String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java b/src/main/java/com/merge/api/resources/ats/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java index ff6e725d8..577db9367 100644 --- a/src/main/java/com/merge/api/resources/ats/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java +++ b/src/main/java/com/merge/api/resources/ats/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java @@ -30,6 +30,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((RemoteResponse) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializerAttachment objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Attachment objects. + */ + public CompletableFuture list(AttachmentsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Attachment objects. + */ + public CompletableFuture list( + AttachmentsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Attachment object with the given values. + */ + public CompletableFuture create(AttachmentEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Attachment object with the given values. + */ + public CompletableFuture create( + AttachmentEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture retrieve(String id, AttachmentsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture retrieve( + String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Attachment POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Attachment POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/attachments/AsyncRawAttachmentsClient.java b/src/main/java/com/merge/api/resources/ats/attachments/AsyncRawAttachmentsClient.java new file mode 100644 index 000000000..d00f25b89 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/attachments/AsyncRawAttachmentsClient.java @@ -0,0 +1,398 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.attachments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.attachments.requests.AttachmentEndpointRequest; +import com.merge.api.resources.ats.attachments.requests.AttachmentsListRequest; +import com.merge.api.resources.ats.attachments.requests.AttachmentsRetrieveRequest; +import com.merge.api.resources.ats.types.Attachment; +import com.merge.api.resources.ats.types.AttachmentResponse; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedAttachmentList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAttachmentsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAttachmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Attachment objects. + */ + public CompletableFuture> list() { + return list(AttachmentsListRequest.builder().build()); + } + + /** + * Returns a list of Attachment objects. + */ + public CompletableFuture> list(AttachmentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Attachment objects. + */ + public CompletableFuture> list( + AttachmentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/attachments"); + if (request.getCandidateId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "candidate_id", request.getCandidateId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAttachmentList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Attachment object with the given values. + */ + public CompletableFuture> create(AttachmentEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Attachment object with the given values. + */ + public CompletableFuture> create( + AttachmentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/attachments"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AttachmentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, AttachmentsRetrieveRequest.builder().build()); + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture> retrieve(String id, AttachmentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture> retrieve( + String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/attachments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Attachment.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Attachment POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Attachment POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/attachments/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/attachments/AttachmentsClient.java b/src/main/java/com/merge/api/resources/ats/attachments/AttachmentsClient.java index 6460df6fd..44877ae4e 100644 --- a/src/main/java/com/merge/api/resources/ats/attachments/AttachmentsClient.java +++ b/src/main/java/com/merge/api/resources/ats/attachments/AttachmentsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.ats.attachments; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.attachments.requests.AttachmentEndpointRequest; import com.merge.api.resources.ats.attachments.requests.AttachmentsListRequest; @@ -16,279 +12,91 @@ import com.merge.api.resources.ats.types.AttachmentResponse; import com.merge.api.resources.ats.types.MetaResponse; import com.merge.api.resources.ats.types.PaginatedAttachmentList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AttachmentsClient { protected final ClientOptions clientOptions; + private final RawAttachmentsClient rawClient; + public AttachmentsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAttachmentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAttachmentsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Attachment objects. */ public PaginatedAttachmentList list() { - return list(AttachmentsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Attachment objects. */ public PaginatedAttachmentList list(AttachmentsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Attachment objects. */ public PaginatedAttachmentList list(AttachmentsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/attachments"); - if (request.getCandidateId().isPresent()) { - httpUrl.addQueryParameter("candidate_id", request.getCandidateId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAttachmentList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates an Attachment object with the given values. */ public AttachmentResponse create(AttachmentEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates an Attachment object with the given values. */ public AttachmentResponse create(AttachmentEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/attachments"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - properties.put("remote_user_id", request.getRemoteUserId()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AttachmentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Attachment object with the given id. */ public Attachment retrieve(String id) { - return retrieve(id, AttachmentsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Attachment object with the given id. */ public Attachment retrieve(String id, AttachmentsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Attachment object with the given id. */ public Attachment retrieve(String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/attachments") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Attachment.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for Attachment POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Attachment POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/attachments/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/attachments/RawAttachmentsClient.java b/src/main/java/com/merge/api/resources/ats/attachments/RawAttachmentsClient.java new file mode 100644 index 000000000..cfcb94338 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/attachments/RawAttachmentsClient.java @@ -0,0 +1,338 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.attachments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.attachments.requests.AttachmentEndpointRequest; +import com.merge.api.resources.ats.attachments.requests.AttachmentsListRequest; +import com.merge.api.resources.ats.attachments.requests.AttachmentsRetrieveRequest; +import com.merge.api.resources.ats.types.Attachment; +import com.merge.api.resources.ats.types.AttachmentResponse; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedAttachmentList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAttachmentsClient { + protected final ClientOptions clientOptions; + + public RawAttachmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Attachment objects. + */ + public MergeApiHttpResponse list() { + return list(AttachmentsListRequest.builder().build()); + } + + /** + * Returns a list of Attachment objects. + */ + public MergeApiHttpResponse list(AttachmentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Attachment objects. + */ + public MergeApiHttpResponse list( + AttachmentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/attachments"); + if (request.getCandidateId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "candidate_id", request.getCandidateId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAttachmentList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Attachment object with the given values. + */ + public MergeApiHttpResponse create(AttachmentEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Attachment object with the given values. + */ + public MergeApiHttpResponse create( + AttachmentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/attachments"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AttachmentResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Attachment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, AttachmentsRetrieveRequest.builder().build()); + } + + /** + * Returns an Attachment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, AttachmentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Attachment object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/attachments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Attachment.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Attachment POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Attachment POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/attachments/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/attachments/requests/AttachmentsListRequest.java b/src/main/java/com/merge/api/resources/ats/attachments/requests/AttachmentsListRequest.java index 25a4158d6..ba367bbca 100644 --- a/src/main/java/com/merge/api/resources/ats/attachments/requests/AttachmentsListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/attachments/requests/AttachmentsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AttachmentsListRequest.Builder.class) public final class AttachmentsListRequest { + private final Optional> expand; + private final Optional candidateId; private final Optional createdAfter; @@ -29,8 +33,6 @@ public final class AttachmentsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -52,11 +54,11 @@ public final class AttachmentsListRequest { private final Map additionalProperties; private AttachmentsListRequest( + Optional> expand, Optional candidateId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -67,11 +69,11 @@ private AttachmentsListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.candidateId = candidateId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -84,6 +86,14 @@ private AttachmentsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return attachments for this candidate. */ @@ -116,14 +126,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -208,11 +210,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(AttachmentsListRequest other) { - return candidateId.equals(other.candidateId) + return expand.equals(other.expand) + && candidateId.equals(other.candidateId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -227,11 +229,11 @@ private boolean equalTo(AttachmentsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.candidateId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -254,6 +256,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional candidateId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -262,8 +266,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -288,11 +290,11 @@ public static final class Builder { private Builder() {} public Builder from(AttachmentsListRequest other) { + expand(other.getExpand()); candidateId(other.getCandidateId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -305,6 +307,22 @@ public Builder from(AttachmentsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "candidate_id", nulls = Nulls.SKIP) public Builder candidateId(Optional candidateId) { this.candidateId = candidateId; @@ -349,17 +367,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -461,11 +468,11 @@ public Builder showEnumOrigins(String showEnumOrigins) { public AttachmentsListRequest build() { return new AttachmentsListRequest( + expand, candidateId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/attachments/requests/AttachmentsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/attachments/requests/AttachmentsRetrieveRequest.java index d4c64ee9d..7b74b1437 100644 --- a/src/main/java/com/merge/api/resources/ats/attachments/requests/AttachmentsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/attachments/requests/AttachmentsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,10 +22,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AttachmentsRetrieveRequest.Builder.class) public final class AttachmentsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -31,13 +35,15 @@ public final class AttachmentsRetrieveRequest { private final Map additionalProperties; private AttachmentsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -47,7 +53,7 @@ private AttachmentsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -59,6 +65,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -89,13 +103,15 @@ public Map getAdditionalProperties() { private boolean equalTo(AttachmentsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -109,10 +125,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -125,22 +143,28 @@ private Builder() {} public Builder from(AttachmentsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -152,6 +176,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -176,7 +211,7 @@ public Builder showEnumOrigins(String showEnumOrigins) { public AttachmentsRetrieveRequest build() { return new AttachmentsRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/audittrail/AsyncAuditTrailClient.java b/src/main/java/com/merge/api/resources/ats/audittrail/AsyncAuditTrailClient.java new file mode 100644 index 000000000..f77343184 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/audittrail/AsyncAuditTrailClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.audittrail; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.ats.types.PaginatedAuditLogEventList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAuditTrailClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAuditTrailClient rawClient; + + public AsyncAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAuditTrailClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAuditTrailClient withRawResponse() { + return this.rawClient; + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list(AuditTrailListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list( + AuditTrailListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/audittrail/AsyncRawAuditTrailClient.java b/src/main/java/com/merge/api/resources/ats/audittrail/AsyncRawAuditTrailClient.java new file mode 100644 index 000000000..6cec88cf6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/audittrail/AsyncRawAuditTrailClient.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.ats.types.PaginatedAuditLogEventList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAuditTrailClient { + protected final ClientOptions clientOptions; + + public AsyncRawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAuditLogEventList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/audittrail/AuditTrailClient.java b/src/main/java/com/merge/api/resources/ats/audittrail/AuditTrailClient.java index f664bcb86..a04cb4828 100644 --- a/src/main/java/com/merge/api/resources/ats/audittrail/AuditTrailClient.java +++ b/src/main/java/com/merge/api/resources/ats/audittrail/AuditTrailClient.java @@ -3,90 +3,46 @@ */ package com.merge.api.resources.ats.audittrail; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.audittrail.requests.AuditTrailListRequest; import com.merge.api.resources.ats.types.PaginatedAuditLogEventList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AuditTrailClient { protected final ClientOptions clientOptions; + private final RawAuditTrailClient rawClient; + public AuditTrailClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAuditTrailClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAuditTrailClient withRawResponse() { + return this.rawClient; } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list() { - return list(AuditTrailListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/audit-trail"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEventType().isPresent()) { - httpUrl.addQueryParameter("event_type", request.getEventType().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getUserEmail().isPresent()) { - httpUrl.addQueryParameter("user_email", request.getUserEmail().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/audittrail/RawAuditTrailClient.java b/src/main/java/com/merge/api/resources/ats/audittrail/RawAuditTrailClient.java new file mode 100644 index 000000000..eda20de86 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/audittrail/RawAuditTrailClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.ats.types.PaginatedAuditLogEventList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAuditTrailClient { + protected final ClientOptions clientOptions; + + public RawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/audittrail/requests/AuditTrailListRequest.java b/src/main/java/com/merge/api/resources/ats/audittrail/requests/AuditTrailListRequest.java index 930558b93..638f363c7 100644 --- a/src/main/java/com/merge/api/resources/ats/audittrail/requests/AuditTrailListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/audittrail/requests/AuditTrailListRequest.java @@ -68,7 +68,7 @@ public Optional getEndDate() { } /** - * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED + * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED */ @JsonProperty("event_type") public Optional getEventType() { diff --git a/src/main/java/com/merge/api/resources/ats/availableactions/AsyncAvailableActionsClient.java b/src/main/java/com/merge/api/resources/ats/availableactions/AsyncAvailableActionsClient.java new file mode 100644 index 000000000..581677e24 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/availableactions/AsyncAvailableActionsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.availableactions; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.AvailableActions; +import java.util.concurrent.CompletableFuture; + +public class AsyncAvailableActionsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAvailableActionsClient rawClient; + + public AsyncAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAvailableActionsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/availableactions/AsyncRawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/ats/availableactions/AsyncRawAvailableActionsClient.java new file mode 100644 index 000000000..3dd58836e --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/availableactions/AsyncRawAvailableActionsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.AvailableActions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/availableactions/AvailableActionsClient.java b/src/main/java/com/merge/api/resources/ats/availableactions/AvailableActionsClient.java index f8daac9b3..fceed2df2 100644 --- a/src/main/java/com/merge/api/resources/ats/availableactions/AvailableActionsClient.java +++ b/src/main/java/com/merge/api/resources/ats/availableactions/AvailableActionsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.ats.availableactions; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.types.AvailableActions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AvailableActionsClient { protected final ClientOptions clientOptions; + private final RawAvailableActionsClient rawClient; + public AvailableActionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAvailableActionsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/available-actions") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/availableactions/RawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/ats/availableactions/RawAvailableActionsClient.java new file mode 100644 index 000000000..e7b41c9be --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/availableactions/RawAvailableActionsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.AvailableActions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public RawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/candidates/AsyncCandidatesClient.java b/src/main/java/com/merge/api/resources/ats/candidates/AsyncCandidatesClient.java new file mode 100644 index 000000000..4ecb29783 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/candidates/AsyncCandidatesClient.java @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.candidates; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.candidates.requests.CandidateEndpointRequest; +import com.merge.api.resources.ats.candidates.requests.CandidatesListRequest; +import com.merge.api.resources.ats.candidates.requests.CandidatesRetrieveRequest; +import com.merge.api.resources.ats.candidates.requests.PatchedCandidateEndpointRequest; +import com.merge.api.resources.ats.types.Candidate; +import com.merge.api.resources.ats.types.CandidateResponse; +import com.merge.api.resources.ats.types.IgnoreCommonModelRequest; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedCandidateList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCandidatesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCandidatesClient rawClient; + + public AsyncCandidatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCandidatesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCandidatesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Candidate objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Candidate objects. + */ + public CompletableFuture list(CandidatesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Candidate objects. + */ + public CompletableFuture list( + CandidatesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Candidate object with the given values. + */ + public CompletableFuture create(CandidateEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Candidate object with the given values. + */ + public CompletableFuture create( + CandidateEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Candidate object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Candidate object with the given id. + */ + public CompletableFuture retrieve(String id, CandidatesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Candidate object with the given id. + */ + public CompletableFuture retrieve( + String id, CandidatesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates a Candidate object with the given id. + */ + public CompletableFuture partialUpdate(String id, PatchedCandidateEndpointRequest request) { + return this.rawClient.partialUpdate(id, request).thenApply(response -> response.body()); + } + + /** + * Updates a Candidate object with the given id. + */ + public CompletableFuture partialUpdate( + String id, PatchedCandidateEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.partialUpdate(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture ignoreCreate(String modelId, IgnoreCommonModelRequest request) { + return this.rawClient.ignoreCreate(modelId, request).thenApply(response -> response.body()); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + return this.rawClient.ignoreCreate(modelId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Candidate PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id) { + return this.rawClient.metaPatchRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Candidate PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id, RequestOptions requestOptions) { + return this.rawClient.metaPatchRetrieve(id, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Candidate POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Candidate POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/candidates/AsyncRawCandidatesClient.java b/src/main/java/com/merge/api/resources/ats/candidates/AsyncRawCandidatesClient.java new file mode 100644 index 000000000..b50d1634b --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/candidates/AsyncRawCandidatesClient.java @@ -0,0 +1,596 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.candidates; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.candidates.requests.CandidateEndpointRequest; +import com.merge.api.resources.ats.candidates.requests.CandidatesListRequest; +import com.merge.api.resources.ats.candidates.requests.CandidatesRetrieveRequest; +import com.merge.api.resources.ats.candidates.requests.PatchedCandidateEndpointRequest; +import com.merge.api.resources.ats.types.Candidate; +import com.merge.api.resources.ats.types.CandidateResponse; +import com.merge.api.resources.ats.types.IgnoreCommonModelRequest; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedCandidateList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCandidatesClient { + protected final ClientOptions clientOptions; + + public AsyncRawCandidatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Candidate objects. + */ + public CompletableFuture> list() { + return list(CandidatesListRequest.builder().build()); + } + + /** + * Returns a list of Candidate objects. + */ + public CompletableFuture> list(CandidatesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Candidate objects. + */ + public CompletableFuture> list( + CandidatesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmailAddresses().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email_addresses", request.getEmailAddresses().get(), false); + } + if (request.getFirstName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "first_name", request.getFirstName().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getLastName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "last_name", request.getLastName().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTags().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tags", request.getTags().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedCandidateList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Candidate object with the given values. + */ + public CompletableFuture> create(CandidateEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Candidate object with the given values. + */ + public CompletableFuture> create( + CandidateEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CandidateResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Candidate object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, CandidatesRetrieveRequest.builder().build()); + } + + /** + * Returns a Candidate object with the given id. + */ + public CompletableFuture> retrieve(String id, CandidatesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Candidate object with the given id. + */ + public CompletableFuture> retrieve( + String id, CandidatesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Candidate.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Updates a Candidate object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedCandidateEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates a Candidate object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedCandidateEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CandidateResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture> ignoreCreate( + String modelId, IgnoreCommonModelRequest request) { + return ignoreCreate(modelId, request, null); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture> ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates/ignore") + .addPathSegment(modelId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Candidate PATCHs. + */ + public CompletableFuture> metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Candidate PATCHs. + */ + public CompletableFuture> metaPatchRetrieve( + String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Candidate POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Candidate POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/candidates/CandidatesClient.java b/src/main/java/com/merge/api/resources/ats/candidates/CandidatesClient.java index 09f378046..0473d8222 100644 --- a/src/main/java/com/merge/api/resources/ats/candidates/CandidatesClient.java +++ b/src/main/java/com/merge/api/resources/ats/candidates/CandidatesClient.java @@ -3,258 +3,96 @@ */ package com.merge.api.resources.ats.candidates; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.candidates.requests.CandidateEndpointRequest; import com.merge.api.resources.ats.candidates.requests.CandidatesListRequest; import com.merge.api.resources.ats.candidates.requests.CandidatesRetrieveRequest; -import com.merge.api.resources.ats.candidates.requests.IgnoreCommonModelRequest; import com.merge.api.resources.ats.candidates.requests.PatchedCandidateEndpointRequest; import com.merge.api.resources.ats.types.Candidate; import com.merge.api.resources.ats.types.CandidateResponse; +import com.merge.api.resources.ats.types.IgnoreCommonModelRequest; import com.merge.api.resources.ats.types.MetaResponse; import com.merge.api.resources.ats.types.PaginatedCandidateList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class CandidatesClient { protected final ClientOptions clientOptions; + private final RawCandidatesClient rawClient; + public CandidatesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCandidatesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCandidatesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Candidate objects. */ public PaginatedCandidateList list() { - return list(CandidatesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Candidate objects. */ public PaginatedCandidateList list(CandidatesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Candidate objects. */ public PaginatedCandidateList list(CandidatesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/candidates"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmailAddresses().isPresent()) { - httpUrl.addQueryParameter( - "email_addresses", request.getEmailAddresses().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getFirstName().isPresent()) { - httpUrl.addQueryParameter("first_name", request.getFirstName().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getLastName().isPresent()) { - httpUrl.addQueryParameter("last_name", request.getLastName().get()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getTags().isPresent()) { - httpUrl.addQueryParameter("tags", request.getTags().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCandidateList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Candidate object with the given values. */ public CandidateResponse create(CandidateEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Candidate object with the given values. */ public CandidateResponse create(CandidateEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/candidates"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - properties.put("remote_user_id", request.getRemoteUserId()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CandidateResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Candidate object with the given id. */ public Candidate retrieve(String id) { - return retrieve(id, CandidatesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Candidate object with the given id. */ public Candidate retrieve(String id, CandidatesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Candidate object with the given id. */ public Candidate retrieve(String id, CandidatesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/candidates") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Candidate.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Updates a Candidate object with the given id. */ public CandidateResponse partialUpdate(String id, PatchedCandidateEndpointRequest request) { - return partialUpdate(id, request, null); + return this.rawClient.partialUpdate(id, request).body(); } /** @@ -262,181 +100,48 @@ public CandidateResponse partialUpdate(String id, PatchedCandidateEndpointReques */ public CandidateResponse partialUpdate( String id, PatchedCandidateEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/candidates") - .addPathSegment(id); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - properties.put("remote_user_id", request.getRemoteUserId()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CandidateResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.partialUpdate(id, request, requestOptions).body(); } /** * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. */ public void ignoreCreate(String modelId, IgnoreCommonModelRequest request) { - ignoreCreate(modelId, request, null); + this.rawClient.ignoreCreate(modelId, request).body(); } /** * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. */ public void ignoreCreate(String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/candidates/ignore") - .addPathSegment(modelId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + this.rawClient.ignoreCreate(modelId, request, requestOptions).body(); } /** * Returns metadata for Candidate PATCHs. */ public MetaResponse metaPatchRetrieve(String id) { - return metaPatchRetrieve(id, null); + return this.rawClient.metaPatchRetrieve(id).body(); } /** * Returns metadata for Candidate PATCHs. */ public MetaResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/candidates/meta/patch") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPatchRetrieve(id, requestOptions).body(); } /** * Returns metadata for Candidate POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Candidate POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/candidates/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/candidates/RawCandidatesClient.java b/src/main/java/com/merge/api/resources/ats/candidates/RawCandidatesClient.java new file mode 100644 index 000000000..f5983dbf8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/candidates/RawCandidatesClient.java @@ -0,0 +1,493 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.candidates; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.candidates.requests.CandidateEndpointRequest; +import com.merge.api.resources.ats.candidates.requests.CandidatesListRequest; +import com.merge.api.resources.ats.candidates.requests.CandidatesRetrieveRequest; +import com.merge.api.resources.ats.candidates.requests.PatchedCandidateEndpointRequest; +import com.merge.api.resources.ats.types.Candidate; +import com.merge.api.resources.ats.types.CandidateResponse; +import com.merge.api.resources.ats.types.IgnoreCommonModelRequest; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedCandidateList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCandidatesClient { + protected final ClientOptions clientOptions; + + public RawCandidatesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Candidate objects. + */ + public MergeApiHttpResponse list() { + return list(CandidatesListRequest.builder().build()); + } + + /** + * Returns a list of Candidate objects. + */ + public MergeApiHttpResponse list(CandidatesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Candidate objects. + */ + public MergeApiHttpResponse list( + CandidatesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmailAddresses().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email_addresses", request.getEmailAddresses().get(), false); + } + if (request.getFirstName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "first_name", request.getFirstName().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getLastName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "last_name", request.getLastName().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTags().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tags", request.getTags().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCandidateList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Candidate object with the given values. + */ + public MergeApiHttpResponse create(CandidateEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Candidate object with the given values. + */ + public MergeApiHttpResponse create( + CandidateEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CandidateResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Candidate object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, CandidatesRetrieveRequest.builder().build()); + } + + /** + * Returns a Candidate object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, CandidatesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Candidate object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, CandidatesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Candidate.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Updates a Candidate object with the given id. + */ + public MergeApiHttpResponse partialUpdate(String id, PatchedCandidateEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates a Candidate object with the given id. + */ + public MergeApiHttpResponse partialUpdate( + String id, PatchedCandidateEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CandidateResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public MergeApiHttpResponse ignoreCreate(String modelId, IgnoreCommonModelRequest request) { + return ignoreCreate(modelId, request, null); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public MergeApiHttpResponse ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates/ignore") + .addPathSegment(modelId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Candidate PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Candidate PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Candidate POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Candidate POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/candidates/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/candidates/requests/CandidatesListRequest.java b/src/main/java/com/merge/api/resources/ats/candidates/requests/CandidatesListRequest.java index fadbc5732..dd848351f 100644 --- a/src/main/java/com/merge/api/resources/ats/candidates/requests/CandidatesListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/candidates/requests/CandidatesListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.candidates.types.CandidatesListRequestExpand; +import com.merge.api.resources.ats.candidates.types.CandidatesListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CandidatesListRequest.Builder.class) public final class CandidatesListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; @@ -30,8 +34,6 @@ public final class CandidatesListRequest { private final Optional emailAddresses; - private final Optional expand; - private final Optional firstName; private final Optional includeDeletedData; @@ -55,11 +57,11 @@ public final class CandidatesListRequest { private final Map additionalProperties; private CandidatesListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, Optional emailAddresses, - Optional expand, Optional firstName, Optional includeDeletedData, Optional includeRemoteData, @@ -71,11 +73,11 @@ private CandidatesListRequest( Optional remoteId, Optional tags, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.emailAddresses = emailAddresses; - this.expand = expand; this.firstName = firstName; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; @@ -89,6 +91,14 @@ private CandidatesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -121,14 +131,6 @@ public Optional getEmailAddresses() { return emailAddresses; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return If provided, will only return candidates with this first name. */ @@ -221,11 +223,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(CandidatesListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && emailAddresses.equals(other.emailAddresses) - && expand.equals(other.expand) && firstName.equals(other.firstName) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) @@ -241,11 +243,11 @@ private boolean equalTo(CandidatesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, this.emailAddresses, - this.expand, this.firstName, this.includeDeletedData, this.includeRemoteData, @@ -269,6 +271,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); @@ -277,8 +281,6 @@ public static final class Builder { private Optional emailAddresses = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional firstName = Optional.empty(); private Optional includeDeletedData = Optional.empty(); @@ -305,11 +307,11 @@ public static final class Builder { private Builder() {} public Builder from(CandidatesListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); emailAddresses(other.getEmailAddresses()); - expand(other.getExpand()); firstName(other.getFirstName()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); @@ -323,6 +325,22 @@ public Builder from(CandidatesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(CandidatesListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -367,17 +385,6 @@ public Builder emailAddresses(String emailAddresses) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(CandidatesListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "first_name", nulls = Nulls.SKIP) public Builder firstName(Optional firstName) { this.firstName = firstName; @@ -490,11 +497,11 @@ public Builder tags(String tags) { public CandidatesListRequest build() { return new CandidatesListRequest( + expand, createdAfter, createdBefore, cursor, emailAddresses, - expand, firstName, includeDeletedData, includeRemoteData, diff --git a/src/main/java/com/merge/api/resources/ats/candidates/requests/CandidatesRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/candidates/requests/CandidatesRetrieveRequest.java index a4c19131a..def3309be 100644 --- a/src/main/java/com/merge/api/resources/ats/candidates/requests/CandidatesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/candidates/requests/CandidatesRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.candidates.types.CandidatesRetrieveRequestExpand; +import com.merge.api.resources.ats.candidates.types.CandidatesRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CandidatesRetrieveRequest.Builder.class) public final class CandidatesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private CandidatesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private CandidatesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(CandidatesRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -83,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,20 +113,26 @@ private Builder() {} public Builder from(CandidatesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(CandidatesRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(CandidatesRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -120,8 +144,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public CandidatesRetrieveRequest build() { - return new CandidatesRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new CandidatesRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/candidates/requests/IgnoreCommonModelRequest.java b/src/main/java/com/merge/api/resources/ats/candidates/requests/IgnoreCommonModelRequest.java deleted file mode 100644 index 43579cecc..000000000 --- a/src/main/java/com/merge/api/resources/ats/candidates/requests/IgnoreCommonModelRequest.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.candidates.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.types.ReasonEnum; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = IgnoreCommonModelRequest.Builder.class) -public final class IgnoreCommonModelRequest { - private final ReasonEnum reason; - - private final Optional message; - - private final Map additionalProperties; - - private IgnoreCommonModelRequest( - ReasonEnum reason, Optional message, Map additionalProperties) { - this.reason = reason; - this.message = message; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("reason") - public ReasonEnum getReason() { - return reason; - } - - @JsonProperty("message") - public Optional getMessage() { - return message; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IgnoreCommonModelRequest && equalTo((IgnoreCommonModelRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(IgnoreCommonModelRequest other) { - return reason.equals(other.reason) && message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.reason, this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ReasonStage builder() { - return new Builder(); - } - - public interface ReasonStage { - _FinalStage reason(@NotNull ReasonEnum reason); - - Builder from(IgnoreCommonModelRequest other); - } - - public interface _FinalStage { - IgnoreCommonModelRequest build(); - - _FinalStage message(Optional message); - - _FinalStage message(String message); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ReasonStage, _FinalStage { - private ReasonEnum reason; - - private Optional message = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(IgnoreCommonModelRequest other) { - reason(other.getReason()); - message(other.getMessage()); - return this; - } - - @java.lang.Override - @JsonSetter("reason") - public _FinalStage reason(@NotNull ReasonEnum reason) { - this.reason = reason; - return this; - } - - @java.lang.Override - public _FinalStage message(String message) { - this.message = Optional.ofNullable(message); - return this; - } - - @java.lang.Override - @JsonSetter(value = "message", nulls = Nulls.SKIP) - public _FinalStage message(Optional message) { - this.message = message; - return this; - } - - @java.lang.Override - public IgnoreCommonModelRequest build() { - return new IgnoreCommonModelRequest(reason, message, additionalProperties); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesListRequestExpand.java b/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesListRequestExpand.java deleted file mode 100644 index 887b8b516..000000000 --- a/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.candidates.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CandidatesListRequestExpand { - APPLICATIONS("applications"), - - APPLICATIONS_ATTACHMENTS("applications,attachments"), - - ATTACHMENTS("attachments"); - - private final String value; - - CandidatesListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesListRequestExpandItem.java new file mode 100644 index 000000000..af03bacfc --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.candidates.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CandidatesListRequestExpandItem { + APPLICATIONS("applications"), + + ATTACHMENTS("attachments"); + + private final String value; + + CandidatesListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesRetrieveRequestExpand.java deleted file mode 100644 index 210e8fc4a..000000000 --- a/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesRetrieveRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.candidates.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CandidatesRetrieveRequestExpand { - APPLICATIONS("applications"), - - APPLICATIONS_ATTACHMENTS("applications,attachments"), - - ATTACHMENTS("attachments"); - - private final String value; - - CandidatesRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesRetrieveRequestExpandItem.java new file mode 100644 index 000000000..fe29db8d8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/candidates/types/CandidatesRetrieveRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.candidates.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CandidatesRetrieveRequestExpandItem { + APPLICATIONS("applications"), + + ATTACHMENTS("attachments"); + + private final String value; + + CandidatesRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/deleteaccount/AsyncDeleteAccountClient.java b/src/main/java/com/merge/api/resources/ats/deleteaccount/AsyncDeleteAccountClient.java new file mode 100644 index 000000000..381737833 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/deleteaccount/AsyncDeleteAccountClient.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.deleteaccount; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import java.util.concurrent.CompletableFuture; + +public class AsyncDeleteAccountClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDeleteAccountClient rawClient; + + public AsyncDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDeleteAccountClient withRawResponse() { + return this.rawClient; + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete() { + return this.rawClient.delete().thenApply(response -> response.body()); + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete(RequestOptions requestOptions) { + return this.rawClient.delete(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/deleteaccount/AsyncRawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/ats/deleteaccount/AsyncRawDeleteAccountClient.java new file mode 100644 index 000000000..190e2fd7a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/deleteaccount/AsyncRawDeleteAccountClient.java @@ -0,0 +1,84 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public AsyncRawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/deleteaccount/DeleteAccountClient.java b/src/main/java/com/merge/api/resources/ats/deleteaccount/DeleteAccountClient.java index ffa66f1ce..d9ef0fa1e 100644 --- a/src/main/java/com/merge/api/resources/ats/deleteaccount/DeleteAccountClient.java +++ b/src/main/java/com/merge/api/resources/ats/deleteaccount/DeleteAccountClient.java @@ -3,63 +3,37 @@ */ package com.merge.api.resources.ats.deleteaccount; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class DeleteAccountClient { protected final ClientOptions clientOptions; + private final RawDeleteAccountClient rawClient; + public DeleteAccountClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDeleteAccountClient withRawResponse() { + return this.rawClient; } /** * Delete a linked account. */ public void delete() { - delete(null); + this.rawClient.delete().body(); } /** * Delete a linked account. */ public void delete(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/delete-account") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + this.rawClient.delete(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/deleteaccount/RawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/ats/deleteaccount/RawDeleteAccountClient.java new file mode 100644 index 000000000..017530eb0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/deleteaccount/RawDeleteAccountClient.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public RawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/departments/AsyncDepartmentsClient.java b/src/main/java/com/merge/api/resources/ats/departments/AsyncDepartmentsClient.java new file mode 100644 index 000000000..aed85fa3b --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/departments/AsyncDepartmentsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.departments; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.departments.requests.DepartmentsListRequest; +import com.merge.api.resources.ats.departments.requests.DepartmentsRetrieveRequest; +import com.merge.api.resources.ats.types.Department; +import com.merge.api.resources.ats.types.PaginatedDepartmentList; +import java.util.concurrent.CompletableFuture; + +public class AsyncDepartmentsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDepartmentsClient rawClient; + + public AsyncDepartmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDepartmentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDepartmentsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Department objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Department objects. + */ + public CompletableFuture list(DepartmentsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Department objects. + */ + public CompletableFuture list( + DepartmentsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Department object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Department object with the given id. + */ + public CompletableFuture retrieve(String id, DepartmentsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Department object with the given id. + */ + public CompletableFuture retrieve( + String id, DepartmentsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/departments/AsyncRawDepartmentsClient.java b/src/main/java/com/merge/api/resources/ats/departments/AsyncRawDepartmentsClient.java new file mode 100644 index 000000000..21c6bf508 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/departments/AsyncRawDepartmentsClient.java @@ -0,0 +1,231 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.departments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.departments.requests.DepartmentsListRequest; +import com.merge.api.resources.ats.departments.requests.DepartmentsRetrieveRequest; +import com.merge.api.resources.ats.types.Department; +import com.merge.api.resources.ats.types.PaginatedDepartmentList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDepartmentsClient { + protected final ClientOptions clientOptions; + + public AsyncRawDepartmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Department objects. + */ + public CompletableFuture> list() { + return list(DepartmentsListRequest.builder().build()); + } + + /** + * Returns a list of Department objects. + */ + public CompletableFuture> list(DepartmentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Department objects. + */ + public CompletableFuture> list( + DepartmentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/departments"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedDepartmentList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Department object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, DepartmentsRetrieveRequest.builder().build()); + } + + /** + * Returns a Department object with the given id. + */ + public CompletableFuture> retrieve(String id, DepartmentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Department object with the given id. + */ + public CompletableFuture> retrieve( + String id, DepartmentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/departments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Department.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/departments/DepartmentsClient.java b/src/main/java/com/merge/api/resources/ats/departments/DepartmentsClient.java index 100dae2e1..8edfbb9b9 100644 --- a/src/main/java/com/merge/api/resources/ats/departments/DepartmentsClient.java +++ b/src/main/java/com/merge/api/resources/ats/departments/DepartmentsClient.java @@ -3,164 +3,69 @@ */ package com.merge.api.resources.ats.departments; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.departments.requests.DepartmentsListRequest; import com.merge.api.resources.ats.departments.requests.DepartmentsRetrieveRequest; import com.merge.api.resources.ats.types.Department; import com.merge.api.resources.ats.types.PaginatedDepartmentList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class DepartmentsClient { protected final ClientOptions clientOptions; + private final RawDepartmentsClient rawClient; + public DepartmentsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawDepartmentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDepartmentsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Department objects. */ public PaginatedDepartmentList list() { - return list(DepartmentsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Department objects. */ public PaginatedDepartmentList list(DepartmentsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Department objects. */ public PaginatedDepartmentList list(DepartmentsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/departments"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedDepartmentList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Department object with the given id. */ public Department retrieve(String id) { - return retrieve(id, DepartmentsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Department object with the given id. */ public Department retrieve(String id, DepartmentsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Department object with the given id. */ public Department retrieve(String id, DepartmentsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/departments") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Department.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/departments/RawDepartmentsClient.java b/src/main/java/com/merge/api/resources/ats/departments/RawDepartmentsClient.java new file mode 100644 index 000000000..01fe330f7 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/departments/RawDepartmentsClient.java @@ -0,0 +1,199 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.departments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.departments.requests.DepartmentsListRequest; +import com.merge.api.resources.ats.departments.requests.DepartmentsRetrieveRequest; +import com.merge.api.resources.ats.types.Department; +import com.merge.api.resources.ats.types.PaginatedDepartmentList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDepartmentsClient { + protected final ClientOptions clientOptions; + + public RawDepartmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Department objects. + */ + public MergeApiHttpResponse list() { + return list(DepartmentsListRequest.builder().build()); + } + + /** + * Returns a list of Department objects. + */ + public MergeApiHttpResponse list(DepartmentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Department objects. + */ + public MergeApiHttpResponse list( + DepartmentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/departments"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedDepartmentList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Department object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, DepartmentsRetrieveRequest.builder().build()); + } + + /** + * Returns a Department object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, DepartmentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Department object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, DepartmentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/departments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Department.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/departments/requests/DepartmentsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/departments/requests/DepartmentsRetrieveRequest.java index 4d6e12a29..5824ff811 100644 --- a/src/main/java/com/merge/api/resources/ats/departments/requests/DepartmentsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/departments/requests/DepartmentsRetrieveRequest.java @@ -22,10 +22,16 @@ public final class DepartmentsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private DepartmentsRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private DepartmentsRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(DepartmentsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(DepartmentsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public DepartmentsRetrieveRequest build() { - return new DepartmentsRetrieveRequest(includeRemoteData, additionalProperties); + return new DepartmentsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/eeocs/AsyncEeocsClient.java b/src/main/java/com/merge/api/resources/ats/eeocs/AsyncEeocsClient.java new file mode 100644 index 000000000..f8faab446 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/eeocs/AsyncEeocsClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.eeocs; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.eeocs.requests.EeocsListRequest; +import com.merge.api.resources.ats.eeocs.requests.EeocsRetrieveRequest; +import com.merge.api.resources.ats.types.Eeoc; +import com.merge.api.resources.ats.types.PaginatedEeocList; +import java.util.concurrent.CompletableFuture; + +public class AsyncEeocsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawEeocsClient rawClient; + + public AsyncEeocsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawEeocsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawEeocsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of EEOC objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of EEOC objects. + */ + public CompletableFuture list(EeocsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of EEOC objects. + */ + public CompletableFuture list(EeocsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an EEOC object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an EEOC object with the given id. + */ + public CompletableFuture retrieve(String id, EeocsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an EEOC object with the given id. + */ + public CompletableFuture retrieve(String id, EeocsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/eeocs/AsyncRawEeocsClient.java b/src/main/java/com/merge/api/resources/ats/eeocs/AsyncRawEeocsClient.java new file mode 100644 index 000000000..8b114818c --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/eeocs/AsyncRawEeocsClient.java @@ -0,0 +1,263 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.eeocs; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.eeocs.requests.EeocsListRequest; +import com.merge.api.resources.ats.eeocs.requests.EeocsRetrieveRequest; +import com.merge.api.resources.ats.types.Eeoc; +import com.merge.api.resources.ats.types.PaginatedEeocList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawEeocsClient { + protected final ClientOptions clientOptions; + + public AsyncRawEeocsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of EEOC objects. + */ + public CompletableFuture> list() { + return list(EeocsListRequest.builder().build()); + } + + /** + * Returns a list of EEOC objects. + */ + public CompletableFuture> list(EeocsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of EEOC objects. + */ + public CompletableFuture> list( + EeocsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/eeocs"); + if (request.getCandidateId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "candidate_id", request.getCandidateId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEeocList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an EEOC object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, EeocsRetrieveRequest.builder().build()); + } + + /** + * Returns an EEOC object with the given id. + */ + public CompletableFuture> retrieve(String id, EeocsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an EEOC object with the given id. + */ + public CompletableFuture> retrieve( + String id, EeocsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/eeocs") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Eeoc.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/eeocs/EeocsClient.java b/src/main/java/com/merge/api/resources/ats/eeocs/EeocsClient.java index 7d5366907..e05719e13 100644 --- a/src/main/java/com/merge/api/resources/ats/eeocs/EeocsClient.java +++ b/src/main/java/com/merge/api/resources/ats/eeocs/EeocsClient.java @@ -3,189 +3,69 @@ */ package com.merge.api.resources.ats.eeocs; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.eeocs.requests.EeocsListRequest; import com.merge.api.resources.ats.eeocs.requests.EeocsRetrieveRequest; import com.merge.api.resources.ats.types.Eeoc; import com.merge.api.resources.ats.types.PaginatedEeocList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class EeocsClient { protected final ClientOptions clientOptions; + private final RawEeocsClient rawClient; + public EeocsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawEeocsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawEeocsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of EEOC objects. */ public PaginatedEeocList list() { - return list(EeocsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of EEOC objects. */ public PaginatedEeocList list(EeocsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of EEOC objects. */ public PaginatedEeocList list(EeocsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/eeocs"); - if (request.getCandidateId().isPresent()) { - httpUrl.addQueryParameter("candidate_id", request.getCandidateId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEeocList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an EEOC object with the given id. */ public Eeoc retrieve(String id) { - return retrieve(id, EeocsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an EEOC object with the given id. */ public Eeoc retrieve(String id, EeocsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an EEOC object with the given id. */ public Eeoc retrieve(String id, EeocsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/eeocs") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Eeoc.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/eeocs/RawEeocsClient.java b/src/main/java/com/merge/api/resources/ats/eeocs/RawEeocsClient.java new file mode 100644 index 000000000..7322efe53 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/eeocs/RawEeocsClient.java @@ -0,0 +1,230 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.eeocs; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.eeocs.requests.EeocsListRequest; +import com.merge.api.resources.ats.eeocs.requests.EeocsRetrieveRequest; +import com.merge.api.resources.ats.types.Eeoc; +import com.merge.api.resources.ats.types.PaginatedEeocList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawEeocsClient { + protected final ClientOptions clientOptions; + + public RawEeocsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of EEOC objects. + */ + public MergeApiHttpResponse list() { + return list(EeocsListRequest.builder().build()); + } + + /** + * Returns a list of EEOC objects. + */ + public MergeApiHttpResponse list(EeocsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of EEOC objects. + */ + public MergeApiHttpResponse list(EeocsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/eeocs"); + if (request.getCandidateId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "candidate_id", request.getCandidateId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEeocList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an EEOC object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, EeocsRetrieveRequest.builder().build()); + } + + /** + * Returns an EEOC object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, EeocsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an EEOC object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, EeocsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/eeocs") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Eeoc.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/eeocs/requests/EeocsListRequest.java b/src/main/java/com/merge/api/resources/ats/eeocs/requests/EeocsListRequest.java index 2da87e38d..d1c37adff 100644 --- a/src/main/java/com/merge/api/resources/ats/eeocs/requests/EeocsListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/eeocs/requests/EeocsListRequest.java @@ -15,7 +15,9 @@ import com.merge.api.resources.ats.eeocs.types.EeocsListRequestRemoteFields; import com.merge.api.resources.ats.eeocs.types.EeocsListRequestShowEnumOrigins; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,6 +25,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EeocsListRequest.Builder.class) public final class EeocsListRequest { + private final Optional> expand; + private final Optional candidateId; private final Optional createdAfter; @@ -31,8 +35,6 @@ public final class EeocsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -54,11 +56,11 @@ public final class EeocsListRequest { private final Map additionalProperties; private EeocsListRequest( + Optional> expand, Optional candidateId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -69,11 +71,11 @@ private EeocsListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.candidateId = candidateId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -86,6 +88,14 @@ private EeocsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return EEOC info for this candidate. */ @@ -118,14 +128,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -210,11 +212,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(EeocsListRequest other) { - return candidateId.equals(other.candidateId) + return expand.equals(other.expand) + && candidateId.equals(other.candidateId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -229,11 +231,11 @@ private boolean equalTo(EeocsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.candidateId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -256,6 +258,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional candidateId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -264,8 +268,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -290,11 +292,11 @@ public static final class Builder { private Builder() {} public Builder from(EeocsListRequest other) { + expand(other.getExpand()); candidateId(other.getCandidateId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -307,6 +309,22 @@ public Builder from(EeocsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "candidate_id", nulls = Nulls.SKIP) public Builder candidateId(Optional candidateId) { this.candidateId = candidateId; @@ -351,17 +369,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -463,11 +470,11 @@ public Builder showEnumOrigins(EeocsListRequestShowEnumOrigins showEnumOrigins) public EeocsListRequest build() { return new EeocsListRequest( + expand, candidateId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/eeocs/requests/EeocsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/eeocs/requests/EeocsRetrieveRequest.java index 38f71d42d..13a85634c 100644 --- a/src/main/java/com/merge/api/resources/ats/eeocs/requests/EeocsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/eeocs/requests/EeocsRetrieveRequest.java @@ -14,7 +14,9 @@ import com.merge.api.core.ObjectMappers; import com.merge.api.resources.ats.eeocs.types.EeocsRetrieveRequestRemoteFields; import com.merge.api.resources.ats.eeocs.types.EeocsRetrieveRequestShowEnumOrigins; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,10 +24,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EeocsRetrieveRequest.Builder.class) public final class EeocsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -33,13 +37,15 @@ public final class EeocsRetrieveRequest { private final Map additionalProperties; private EeocsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -49,7 +55,7 @@ private EeocsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -61,6 +67,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -91,13 +105,15 @@ public Map getAdditionalProperties() { private boolean equalTo(EeocsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -111,10 +127,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -127,22 +145,28 @@ private Builder() {} public Builder from(EeocsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -154,6 +178,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -178,7 +213,7 @@ public Builder showEnumOrigins(EeocsRetrieveRequestShowEnumOrigins showEnumOrigi public EeocsRetrieveRequest build() { return new EeocsRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/fieldmapping/AsyncFieldMappingClient.java b/src/main/java/com/merge/api/resources/ats/fieldmapping/AsyncFieldMappingClient.java new file mode 100644 index 000000000..8cb7e2061 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/fieldmapping/AsyncFieldMappingClient.java @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.fieldmapping; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.ats.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.ats.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.ats.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.ats.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.ats.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.ats.types.FieldMappingInstanceResponse; +import com.merge.api.resources.ats.types.RemoteFieldApiResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncFieldMappingClient { + protected final ClientOptions clientOptions; + + private final AsyncRawFieldMappingClient rawClient; + + public AsyncFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawFieldMappingClient withRawResponse() { + return this.rawClient; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve() { + return this.rawClient.fieldMappingsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return this.rawClient.fieldMappingsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate(CreateFieldMappingRequest request) { + return this.rawClient.fieldMappingsCreate(request).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsCreate(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy(String fieldMappingId) { + return this.rawClient.fieldMappingsDestroy(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate(String fieldMappingId) { + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve() { + return this.rawClient.remoteFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return this.rawClient.remoteFieldsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve() { + return this.rawClient.targetFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve(RequestOptions requestOptions) { + return this.rawClient.targetFieldsRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/fieldmapping/AsyncRawFieldMappingClient.java b/src/main/java/com/merge/api/resources/ats/fieldmapping/AsyncRawFieldMappingClient.java new file mode 100644 index 000000000..0198282e8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/fieldmapping/AsyncRawFieldMappingClient.java @@ -0,0 +1,471 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.ats.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.ats.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.ats.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.ats.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.ats.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.ats.types.FieldMappingInstanceResponse; +import com.merge.api.resources.ats.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawFieldMappingClient { + protected final ClientOptions clientOptions; + + public AsyncRawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), RemoteFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/fieldmapping/FieldMappingClient.java b/src/main/java/com/merge/api/resources/ats/fieldmapping/FieldMappingClient.java index ab6e172f0..fec33044a 100644 --- a/src/main/java/com/merge/api/resources/ats/fieldmapping/FieldMappingClient.java +++ b/src/main/java/com/merge/api/resources/ats/fieldmapping/FieldMappingClient.java @@ -3,12 +3,7 @@ */ package com.merge.api.resources.ats.fieldmapping; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.fieldmapping.requests.CreateFieldMappingRequest; import com.merge.api.resources.ats.fieldmapping.requests.FieldMappingsRetrieveRequest; @@ -18,36 +13,36 @@ import com.merge.api.resources.ats.types.FieldMappingApiInstanceResponse; import com.merge.api.resources.ats.types.FieldMappingInstanceResponse; import com.merge.api.resources.ats.types.RemoteFieldApiResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class FieldMappingClient { protected final ClientOptions clientOptions; + private final RawFieldMappingClient rawClient; + public FieldMappingClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawFieldMappingClient withRawResponse() { + return this.rawClient; } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve() { - return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + return this.rawClient.fieldMappingsRetrieve().body(); } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrieveRequest request) { - return fieldMappingsRetrieve(request, null); + return this.rawClient.fieldMappingsRetrieve(request).body(); } /** @@ -55,46 +50,14 @@ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrie */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve( FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), FieldMappingApiInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).body(); } /** * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingRequest request) { - return fieldMappingsCreate(request, null); + return this.rawClient.fieldMappingsCreate(request).body(); } /** @@ -102,102 +65,30 @@ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingReques */ public FieldMappingInstanceResponse fieldMappingsCreate( CreateFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("target_field_name", request.getTargetFieldName()); - properties.put("target_field_description", request.getTargetFieldDescription()); - properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); - properties.put("remote_method", request.getRemoteMethod()); - properties.put("remote_url_path", request.getRemoteUrlPath()); - properties.put("common_model_name", request.getCommonModelName()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsCreate(request, requestOptions).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId) { - return fieldMappingsDestroy(fieldMappingId, null); + return this.rawClient.fieldMappingsDestroy(fieldMappingId).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .body(); } /** * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappingId) { - return fieldMappingsPartialUpdate( - fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).body(); } /** @@ -205,7 +96,9 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappi */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request) { - return fieldMappingsPartialUpdate(fieldMappingId, request, null); + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .body(); } /** @@ -213,56 +106,23 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve() { - return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + return this.rawClient.remoteFieldsRetrieve().body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { - return remoteFieldsRetrieve(request, null); + return this.rawClient.remoteFieldsRetrieve(request).body(); } /** @@ -270,80 +130,20 @@ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest r */ public RemoteFieldApiResponse remoteFieldsRetrieve( RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/remote-fields"); - if (request.getCommonModels().isPresent()) { - httpUrl.addQueryParameter("common_models", request.getCommonModels().get()); - } - if (request.getIncludeExampleValues().isPresent()) { - httpUrl.addQueryParameter( - "include_example_values", request.getIncludeExampleValues().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve() { - return targetFieldsRetrieve(null); + return this.rawClient.targetFieldsRetrieve().body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/target-fields") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalTargetFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.targetFieldsRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/fieldmapping/RawFieldMappingClient.java b/src/main/java/com/merge/api/resources/ats/fieldmapping/RawFieldMappingClient.java new file mode 100644 index 000000000..02f2a87fa --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/fieldmapping/RawFieldMappingClient.java @@ -0,0 +1,380 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.ats.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.ats.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.ats.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.ats.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.ats.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.ats.types.FieldMappingInstanceResponse; +import com.merge.api.resources.ats.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawFieldMappingClient { + protected final ClientOptions clientOptions; + + public RawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate(CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy(String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate(String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/forceresync/AsyncForceResyncClient.java b/src/main/java/com/merge/api/resources/ats/forceresync/AsyncForceResyncClient.java new file mode 100644 index 000000000..9891221a6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/forceresync/AsyncForceResyncClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.forceresync; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.SyncStatus; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncForceResyncClient { + protected final ClientOptions clientOptions; + + private final AsyncRawForceResyncClient rawClient; + + public AsyncForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawForceResyncClient withRawResponse() { + return this.rawClient; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate() { + return this.rawClient.syncStatusResyncCreate().thenApply(response -> response.body()); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate(RequestOptions requestOptions) { + return this.rawClient.syncStatusResyncCreate(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/forceresync/AsyncRawForceResyncClient.java b/src/main/java/com/merge/api/resources/ats/forceresync/AsyncRawForceResyncClient.java new file mode 100644 index 000000000..b6c4018cf --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/forceresync/AsyncRawForceResyncClient.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawForceResyncClient { + protected final ClientOptions clientOptions; + + public AsyncRawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/forceresync/ForceResyncClient.java b/src/main/java/com/merge/api/resources/ats/forceresync/ForceResyncClient.java index 7a15ae0c2..59c69e030 100644 --- a/src/main/java/com/merge/api/resources/ats/forceresync/ForceResyncClient.java +++ b/src/main/java/com/merge/api/resources/ats/forceresync/ForceResyncClient.java @@ -3,69 +3,39 @@ */ package com.merge.api.resources.ats.forceresync; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.types.SyncStatus; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ForceResyncClient { protected final ClientOptions clientOptions; + private final RawForceResyncClient rawClient; + public ForceResyncClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawForceResyncClient withRawResponse() { + return this.rawClient; } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate() { - return syncStatusResyncCreate(null); + return this.rawClient.syncStatusResyncCreate().body(); } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/sync-status/resync") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.syncStatusResyncCreate(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/forceresync/RawForceResyncClient.java b/src/main/java/com/merge/api/resources/ats/forceresync/RawForceResyncClient.java new file mode 100644 index 000000000..0948740db --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/forceresync/RawForceResyncClient.java @@ -0,0 +1,75 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawForceResyncClient { + protected final ClientOptions clientOptions; + + public RawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/generatekey/AsyncGenerateKeyClient.java b/src/main/java/com/merge/api/resources/ats/generatekey/AsyncGenerateKeyClient.java new file mode 100644 index 000000000..6c93f4276 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/generatekey/AsyncGenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.generatekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.ats.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncGenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawGenerateKeyClient rawClient; + + public AsyncGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawGenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/generatekey/AsyncRawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/ats/generatekey/AsyncRawGenerateKeyClient.java new file mode 100644 index 000000000..4aa53e593 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/generatekey/AsyncRawGenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.ats.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public CompletableFuture> create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public CompletableFuture> create( + GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/generatekey/GenerateKeyClient.java b/src/main/java/com/merge/api/resources/ats/generatekey/GenerateKeyClient.java index 9ae57d105..39fdddf4d 100644 --- a/src/main/java/com/merge/api/resources/ats/generatekey/GenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/ats/generatekey/GenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.ats.generatekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.generatekey.requests.GenerateRemoteKeyRequest; import com.merge.api.resources.ats.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class GenerateKeyClient { protected final ClientOptions clientOptions; + private final RawGenerateKeyClient rawClient; + public GenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawGenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/generate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/generatekey/RawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/ats/generatekey/RawGenerateKeyClient.java new file mode 100644 index 000000000..c98f52cdc --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/generatekey/RawGenerateKeyClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.ats.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/interviews/AsyncInterviewsClient.java b/src/main/java/com/merge/api/resources/ats/interviews/AsyncInterviewsClient.java new file mode 100644 index 000000000..fd64d5bdb --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/interviews/AsyncInterviewsClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.interviews; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.interviews.requests.InterviewsListRequest; +import com.merge.api.resources.ats.interviews.requests.InterviewsRetrieveRequest; +import com.merge.api.resources.ats.interviews.requests.ScheduledInterviewEndpointRequest; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedScheduledInterviewList; +import com.merge.api.resources.ats.types.ScheduledInterview; +import com.merge.api.resources.ats.types.ScheduledInterviewResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncInterviewsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawInterviewsClient rawClient; + + public AsyncInterviewsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawInterviewsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawInterviewsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of ScheduledInterview objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of ScheduledInterview objects. + */ + public CompletableFuture list(InterviewsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of ScheduledInterview objects. + */ + public CompletableFuture list( + InterviewsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a ScheduledInterview object with the given values. + */ + public CompletableFuture create(ScheduledInterviewEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a ScheduledInterview object with the given values. + */ + public CompletableFuture create( + ScheduledInterviewEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a ScheduledInterview object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a ScheduledInterview object with the given id. + */ + public CompletableFuture retrieve(String id, InterviewsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a ScheduledInterview object with the given id. + */ + public CompletableFuture retrieve( + String id, InterviewsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for ScheduledInterview POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for ScheduledInterview POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/interviews/AsyncRawInterviewsClient.java b/src/main/java/com/merge/api/resources/ats/interviews/AsyncRawInterviewsClient.java new file mode 100644 index 000000000..70f18e71c --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/interviews/AsyncRawInterviewsClient.java @@ -0,0 +1,417 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.interviews; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.interviews.requests.InterviewsListRequest; +import com.merge.api.resources.ats.interviews.requests.InterviewsRetrieveRequest; +import com.merge.api.resources.ats.interviews.requests.ScheduledInterviewEndpointRequest; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedScheduledInterviewList; +import com.merge.api.resources.ats.types.ScheduledInterview; +import com.merge.api.resources.ats.types.ScheduledInterviewResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawInterviewsClient { + protected final ClientOptions clientOptions; + + public AsyncRawInterviewsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of ScheduledInterview objects. + */ + public CompletableFuture> list() { + return list(InterviewsListRequest.builder().build()); + } + + /** + * Returns a list of ScheduledInterview objects. + */ + public CompletableFuture> list( + InterviewsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of ScheduledInterview objects. + */ + public CompletableFuture> list( + InterviewsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/interviews"); + if (request.getApplicationId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "application_id", request.getApplicationId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getJobId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "job_id", request.getJobId().get(), false); + } + if (request.getJobInterviewStageId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "job_interview_stage_id", + request.getJobInterviewStageId().get(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOrganizerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "organizer_id", request.getOrganizerId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedScheduledInterviewList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a ScheduledInterview object with the given values. + */ + public CompletableFuture> create( + ScheduledInterviewEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a ScheduledInterview object with the given values. + */ + public CompletableFuture> create( + ScheduledInterviewEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/interviews"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ScheduledInterviewResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a ScheduledInterview object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, InterviewsRetrieveRequest.builder().build()); + } + + /** + * Returns a ScheduledInterview object with the given id. + */ + public CompletableFuture> retrieve( + String id, InterviewsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a ScheduledInterview object with the given id. + */ + public CompletableFuture> retrieve( + String id, InterviewsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/interviews") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ScheduledInterview.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for ScheduledInterview POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for ScheduledInterview POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/interviews/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/interviews/InterviewsClient.java b/src/main/java/com/merge/api/resources/ats/interviews/InterviewsClient.java index 44a52af77..72823b169 100644 --- a/src/main/java/com/merge/api/resources/ats/interviews/InterviewsClient.java +++ b/src/main/java/com/merge/api/resources/ats/interviews/InterviewsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.ats.interviews; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.interviews.requests.InterviewsListRequest; import com.merge.api.resources.ats.interviews.requests.InterviewsRetrieveRequest; @@ -16,291 +12,91 @@ import com.merge.api.resources.ats.types.PaginatedScheduledInterviewList; import com.merge.api.resources.ats.types.ScheduledInterview; import com.merge.api.resources.ats.types.ScheduledInterviewResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class InterviewsClient { protected final ClientOptions clientOptions; + private final RawInterviewsClient rawClient; + public InterviewsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawInterviewsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawInterviewsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of ScheduledInterview objects. */ public PaginatedScheduledInterviewList list() { - return list(InterviewsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of ScheduledInterview objects. */ public PaginatedScheduledInterviewList list(InterviewsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of ScheduledInterview objects. */ public PaginatedScheduledInterviewList list(InterviewsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/interviews"); - if (request.getApplicationId().isPresent()) { - httpUrl.addQueryParameter( - "application_id", request.getApplicationId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getJobId().isPresent()) { - httpUrl.addQueryParameter("job_id", request.getJobId().get()); - } - if (request.getJobInterviewStageId().isPresent()) { - httpUrl.addQueryParameter( - "job_interview_stage_id", request.getJobInterviewStageId().get()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getOrganizerId().isPresent()) { - httpUrl.addQueryParameter("organizer_id", request.getOrganizerId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedScheduledInterviewList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a ScheduledInterview object with the given values. */ public ScheduledInterviewResponse create(ScheduledInterviewEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a ScheduledInterview object with the given values. */ public ScheduledInterviewResponse create(ScheduledInterviewEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/interviews"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - properties.put("remote_user_id", request.getRemoteUserId()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ScheduledInterviewResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a ScheduledInterview object with the given id. */ public ScheduledInterview retrieve(String id) { - return retrieve(id, InterviewsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a ScheduledInterview object with the given id. */ public ScheduledInterview retrieve(String id, InterviewsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a ScheduledInterview object with the given id. */ public ScheduledInterview retrieve(String id, InterviewsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/interviews") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ScheduledInterview.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for ScheduledInterview POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for ScheduledInterview POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/interviews/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/interviews/RawInterviewsClient.java b/src/main/java/com/merge/api/resources/ats/interviews/RawInterviewsClient.java new file mode 100644 index 000000000..108922568 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/interviews/RawInterviewsClient.java @@ -0,0 +1,355 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.interviews; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.interviews.requests.InterviewsListRequest; +import com.merge.api.resources.ats.interviews.requests.InterviewsRetrieveRequest; +import com.merge.api.resources.ats.interviews.requests.ScheduledInterviewEndpointRequest; +import com.merge.api.resources.ats.types.MetaResponse; +import com.merge.api.resources.ats.types.PaginatedScheduledInterviewList; +import com.merge.api.resources.ats.types.ScheduledInterview; +import com.merge.api.resources.ats.types.ScheduledInterviewResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawInterviewsClient { + protected final ClientOptions clientOptions; + + public RawInterviewsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of ScheduledInterview objects. + */ + public MergeApiHttpResponse list() { + return list(InterviewsListRequest.builder().build()); + } + + /** + * Returns a list of ScheduledInterview objects. + */ + public MergeApiHttpResponse list(InterviewsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of ScheduledInterview objects. + */ + public MergeApiHttpResponse list( + InterviewsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/interviews"); + if (request.getApplicationId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "application_id", request.getApplicationId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getJobId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "job_id", request.getJobId().get(), false); + } + if (request.getJobInterviewStageId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "job_interview_stage_id", + request.getJobInterviewStageId().get(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOrganizerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "organizer_id", request.getOrganizerId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedScheduledInterviewList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a ScheduledInterview object with the given values. + */ + public MergeApiHttpResponse create(ScheduledInterviewEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a ScheduledInterview object with the given values. + */ + public MergeApiHttpResponse create( + ScheduledInterviewEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/interviews"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + properties.put("remote_user_id", request.getRemoteUserId()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ScheduledInterviewResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a ScheduledInterview object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, InterviewsRetrieveRequest.builder().build()); + } + + /** + * Returns a ScheduledInterview object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, InterviewsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a ScheduledInterview object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, InterviewsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/interviews") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ScheduledInterview.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for ScheduledInterview POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for ScheduledInterview POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/interviews/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/interviews/requests/InterviewsListRequest.java b/src/main/java/com/merge/api/resources/ats/interviews/requests/InterviewsListRequest.java index 0296b8a99..7f6335b5f 100644 --- a/src/main/java/com/merge/api/resources/ats/interviews/requests/InterviewsListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/interviews/requests/InterviewsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.interviews.types.InterviewsListRequestExpand; +import com.merge.api.resources.ats.interviews.types.InterviewsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = InterviewsListRequest.Builder.class) public final class InterviewsListRequest { + private final Optional> expand; + private final Optional applicationId; private final Optional createdAfter; @@ -30,8 +34,6 @@ public final class InterviewsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -59,11 +61,11 @@ public final class InterviewsListRequest { private final Map additionalProperties; private InterviewsListRequest( + Optional> expand, Optional applicationId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -77,11 +79,11 @@ private InterviewsListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.applicationId = applicationId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -97,6 +99,14 @@ private InterviewsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return interviews for this application. */ @@ -129,14 +139,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -245,11 +247,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(InterviewsListRequest other) { - return applicationId.equals(other.applicationId) + return expand.equals(other.expand) + && applicationId.equals(other.applicationId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -267,11 +269,11 @@ private boolean equalTo(InterviewsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.applicationId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -297,6 +299,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional applicationId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -305,8 +309,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -337,11 +339,11 @@ public static final class Builder { private Builder() {} public Builder from(InterviewsListRequest other) { + expand(other.getExpand()); applicationId(other.getApplicationId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -357,6 +359,22 @@ public Builder from(InterviewsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(InterviewsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "application_id", nulls = Nulls.SKIP) public Builder applicationId(Optional applicationId) { this.applicationId = applicationId; @@ -401,17 +419,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(InterviewsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -546,11 +553,11 @@ public Builder showEnumOrigins(String showEnumOrigins) { public InterviewsListRequest build() { return new InterviewsListRequest( + expand, applicationId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/interviews/requests/InterviewsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/interviews/requests/InterviewsRetrieveRequest.java index 5444be32f..f39dac638 100644 --- a/src/main/java/com/merge/api/resources/ats/interviews/requests/InterviewsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/interviews/requests/InterviewsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.interviews.types.InterviewsRetrieveRequestExpand; +import com.merge.api.resources.ats.interviews.types.InterviewsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,10 +23,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = InterviewsRetrieveRequest.Builder.class) public final class InterviewsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -32,13 +36,15 @@ public final class InterviewsRetrieveRequest { private final Map additionalProperties; private InterviewsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -48,7 +54,7 @@ private InterviewsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -60,6 +66,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -90,13 +104,15 @@ public Map getAdditionalProperties() { private boolean equalTo(InterviewsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -110,10 +126,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -126,22 +144,28 @@ private Builder() {} public Builder from(InterviewsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(InterviewsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(InterviewsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -153,6 +177,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -177,7 +212,7 @@ public Builder showEnumOrigins(String showEnumOrigins) { public InterviewsRetrieveRequest build() { return new InterviewsRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsListRequestExpand.java b/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsListRequestExpand.java deleted file mode 100644 index cf0c863be..000000000 --- a/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsListRequestExpand.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.interviews.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum InterviewsListRequestExpand { - APPLICATION("application"), - - APPLICATION_JOB_INTERVIEW_STAGE("application,job_interview_stage"), - - INTERVIEWERS("interviewers"), - - INTERVIEWERS_APPLICATION("interviewers,application"), - - INTERVIEWERS_APPLICATION_JOB_INTERVIEW_STAGE("interviewers,application,job_interview_stage"), - - INTERVIEWERS_JOB_INTERVIEW_STAGE("interviewers,job_interview_stage"), - - INTERVIEWERS_ORGANIZER("interviewers,organizer"), - - INTERVIEWERS_ORGANIZER_APPLICATION("interviewers,organizer,application"), - - INTERVIEWERS_ORGANIZER_APPLICATION_JOB_INTERVIEW_STAGE("interviewers,organizer,application,job_interview_stage"), - - INTERVIEWERS_ORGANIZER_JOB_INTERVIEW_STAGE("interviewers,organizer,job_interview_stage"), - - JOB_INTERVIEW_STAGE("job_interview_stage"), - - ORGANIZER("organizer"), - - ORGANIZER_APPLICATION("organizer,application"), - - ORGANIZER_APPLICATION_JOB_INTERVIEW_STAGE("organizer,application,job_interview_stage"), - - ORGANIZER_JOB_INTERVIEW_STAGE("organizer,job_interview_stage"); - - private final String value; - - InterviewsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsListRequestExpandItem.java new file mode 100644 index 000000000..c2fb0562a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsListRequestExpandItem.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.interviews.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum InterviewsListRequestExpandItem { + APPLICATION("application"), + + INTERVIEWERS("interviewers"), + + JOB_INTERVIEW_STAGE("job_interview_stage"), + + ORGANIZER("organizer"); + + private final String value; + + InterviewsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsRetrieveRequestExpand.java deleted file mode 100644 index c68cc5cfc..000000000 --- a/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsRetrieveRequestExpand.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.interviews.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum InterviewsRetrieveRequestExpand { - APPLICATION("application"), - - APPLICATION_JOB_INTERVIEW_STAGE("application,job_interview_stage"), - - INTERVIEWERS("interviewers"), - - INTERVIEWERS_APPLICATION("interviewers,application"), - - INTERVIEWERS_APPLICATION_JOB_INTERVIEW_STAGE("interviewers,application,job_interview_stage"), - - INTERVIEWERS_JOB_INTERVIEW_STAGE("interviewers,job_interview_stage"), - - INTERVIEWERS_ORGANIZER("interviewers,organizer"), - - INTERVIEWERS_ORGANIZER_APPLICATION("interviewers,organizer,application"), - - INTERVIEWERS_ORGANIZER_APPLICATION_JOB_INTERVIEW_STAGE("interviewers,organizer,application,job_interview_stage"), - - INTERVIEWERS_ORGANIZER_JOB_INTERVIEW_STAGE("interviewers,organizer,job_interview_stage"), - - JOB_INTERVIEW_STAGE("job_interview_stage"), - - ORGANIZER("organizer"), - - ORGANIZER_APPLICATION("organizer,application"), - - ORGANIZER_APPLICATION_JOB_INTERVIEW_STAGE("organizer,application,job_interview_stage"), - - ORGANIZER_JOB_INTERVIEW_STAGE("organizer,job_interview_stage"); - - private final String value; - - InterviewsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..4768c236b --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/interviews/types/InterviewsRetrieveRequestExpandItem.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.interviews.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum InterviewsRetrieveRequestExpandItem { + APPLICATION("application"), + + INTERVIEWERS("interviewers"), + + JOB_INTERVIEW_STAGE("job_interview_stage"), + + ORGANIZER("organizer"); + + private final String value; + + InterviewsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/issues/AsyncIssuesClient.java b/src/main/java/com/merge/api/resources/ats/issues/AsyncIssuesClient.java new file mode 100644 index 000000000..ef05c386d --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/issues/AsyncIssuesClient.java @@ -0,0 +1,64 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.issues; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.issues.requests.IssuesListRequest; +import com.merge.api.resources.ats.types.Issue; +import com.merge.api.resources.ats.types.PaginatedIssueList; +import java.util.concurrent.CompletableFuture; + +public class AsyncIssuesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawIssuesClient rawClient; + + public AsyncIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawIssuesClient withRawResponse() { + return this.rawClient; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/issues/AsyncRawIssuesClient.java b/src/main/java/com/merge/api/resources/ats/issues/AsyncRawIssuesClient.java new file mode 100644 index 000000000..f5e62e486 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/issues/AsyncRawIssuesClient.java @@ -0,0 +1,226 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.issues.requests.IssuesListRequest; +import com.merge.api.resources.ats.types.Issue; +import com.merge.api.resources.ats.types.PaginatedIssueList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawIssuesClient { + protected final ClientOptions clientOptions; + + public AsyncRawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list( + IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/issues/IssuesClient.java b/src/main/java/com/merge/api/resources/ats/issues/IssuesClient.java index 38ba10ac0..5896a7eda 100644 --- a/src/main/java/com/merge/api/resources/ats/issues/IssuesClient.java +++ b/src/main/java/com/merge/api/resources/ats/issues/IssuesClient.java @@ -3,169 +3,61 @@ */ package com.merge.api.resources.ats.issues; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.issues.requests.IssuesListRequest; import com.merge.api.resources.ats.types.Issue; import com.merge.api.resources.ats.types.PaginatedIssueList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class IssuesClient { protected final ClientOptions clientOptions; + private final RawIssuesClient rawClient; + public IssuesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawIssuesClient withRawResponse() { + return this.rawClient; } /** * Gets all issues for Organization. */ public PaginatedIssueList list() { - return list(IssuesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/issues"); - if (request.getAccountToken().isPresent()) { - httpUrl.addQueryParameter("account_token", request.getAccountToken().get()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getFirstIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_after", - request.getFirstIncidentTimeAfter().get().toString()); - } - if (request.getFirstIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_before", - request.getFirstIncidentTimeBefore().get().toString()); - } - if (request.getIncludeMuted().isPresent()) { - httpUrl.addQueryParameter("include_muted", request.getIncludeMuted().get()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getLastIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_after", - request.getLastIncidentTimeAfter().get().toString()); - } - if (request.getLastIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_before", - request.getLastIncidentTimeBefore().get().toString()); - } - if (request.getLinkedAccountId().isPresent()) { - httpUrl.addQueryParameter( - "linked_account_id", request.getLinkedAccountId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Get a specific issue. */ public Issue retrieve(String id) { - return retrieve(id, null); + return this.rawClient.retrieve(id).body(); } /** * Get a specific issue. */ public Issue retrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/issues") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/issues/RawIssuesClient.java b/src/main/java/com/merge/api/resources/ats/issues/RawIssuesClient.java new file mode 100644 index 000000000..0b97c4fad --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/issues/RawIssuesClient.java @@ -0,0 +1,194 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.issues.requests.IssuesListRequest; +import com.merge.api.resources.ats.types.Issue; +import com.merge.api.resources.ats.types.PaginatedIssueList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawIssuesClient { + protected final ClientOptions clientOptions; + + public RawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobinterviewstages/AsyncJobInterviewStagesClient.java b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/AsyncJobInterviewStagesClient.java new file mode 100644 index 000000000..6e4c1a292 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/AsyncJobInterviewStagesClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobinterviewstages; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.jobinterviewstages.requests.JobInterviewStagesListRequest; +import com.merge.api.resources.ats.jobinterviewstages.requests.JobInterviewStagesRetrieveRequest; +import com.merge.api.resources.ats.types.JobInterviewStage; +import com.merge.api.resources.ats.types.PaginatedJobInterviewStageList; +import java.util.concurrent.CompletableFuture; + +public class AsyncJobInterviewStagesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawJobInterviewStagesClient rawClient; + + public AsyncJobInterviewStagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawJobInterviewStagesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawJobInterviewStagesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of JobInterviewStage objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of JobInterviewStage objects. + */ + public CompletableFuture list(JobInterviewStagesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of JobInterviewStage objects. + */ + public CompletableFuture list( + JobInterviewStagesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a JobInterviewStage object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a JobInterviewStage object with the given id. + */ + public CompletableFuture retrieve(String id, JobInterviewStagesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a JobInterviewStage object with the given id. + */ + public CompletableFuture retrieve( + String id, JobInterviewStagesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobinterviewstages/AsyncRawJobInterviewStagesClient.java b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/AsyncRawJobInterviewStagesClient.java new file mode 100644 index 000000000..1e0ac9a49 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/AsyncRawJobInterviewStagesClient.java @@ -0,0 +1,245 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobinterviewstages; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.jobinterviewstages.requests.JobInterviewStagesListRequest; +import com.merge.api.resources.ats.jobinterviewstages.requests.JobInterviewStagesRetrieveRequest; +import com.merge.api.resources.ats.types.JobInterviewStage; +import com.merge.api.resources.ats.types.PaginatedJobInterviewStageList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawJobInterviewStagesClient { + protected final ClientOptions clientOptions; + + public AsyncRawJobInterviewStagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of JobInterviewStage objects. + */ + public CompletableFuture> list() { + return list(JobInterviewStagesListRequest.builder().build()); + } + + /** + * Returns a list of JobInterviewStage objects. + */ + public CompletableFuture> list( + JobInterviewStagesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of JobInterviewStage objects. + */ + public CompletableFuture> list( + JobInterviewStagesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/job-interview-stages"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getJobId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "job_id", request.getJobId().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedJobInterviewStageList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a JobInterviewStage object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, JobInterviewStagesRetrieveRequest.builder().build()); + } + + /** + * Returns a JobInterviewStage object with the given id. + */ + public CompletableFuture> retrieve( + String id, JobInterviewStagesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a JobInterviewStage object with the given id. + */ + public CompletableFuture> retrieve( + String id, JobInterviewStagesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/job-interview-stages") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JobInterviewStage.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobinterviewstages/JobInterviewStagesClient.java b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/JobInterviewStagesClient.java index 0273c4c67..80cc85cd1 100644 --- a/src/main/java/com/merge/api/resources/ats/jobinterviewstages/JobInterviewStagesClient.java +++ b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/JobInterviewStagesClient.java @@ -3,133 +3,63 @@ */ package com.merge.api.resources.ats.jobinterviewstages; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.jobinterviewstages.requests.JobInterviewStagesListRequest; import com.merge.api.resources.ats.jobinterviewstages.requests.JobInterviewStagesRetrieveRequest; import com.merge.api.resources.ats.types.JobInterviewStage; import com.merge.api.resources.ats.types.PaginatedJobInterviewStageList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class JobInterviewStagesClient { protected final ClientOptions clientOptions; + private final RawJobInterviewStagesClient rawClient; + public JobInterviewStagesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawJobInterviewStagesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawJobInterviewStagesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of JobInterviewStage objects. */ public PaginatedJobInterviewStageList list() { - return list(JobInterviewStagesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of JobInterviewStage objects. */ public PaginatedJobInterviewStageList list(JobInterviewStagesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of JobInterviewStage objects. */ public PaginatedJobInterviewStageList list(JobInterviewStagesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/job-interview-stages"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getJobId().isPresent()) { - httpUrl.addQueryParameter("job_id", request.getJobId().get()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedJobInterviewStageList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a JobInterviewStage object with the given id. */ public JobInterviewStage retrieve(String id) { - return retrieve(id, JobInterviewStagesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a JobInterviewStage object with the given id. */ public JobInterviewStage retrieve(String id, JobInterviewStagesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** @@ -137,40 +67,6 @@ public JobInterviewStage retrieve(String id, JobInterviewStagesRetrieveRequest r */ public JobInterviewStage retrieve( String id, JobInterviewStagesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/job-interview-stages") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JobInterviewStage.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/jobinterviewstages/RawJobInterviewStagesClient.java b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/RawJobInterviewStagesClient.java new file mode 100644 index 000000000..394a4e02e --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/RawJobInterviewStagesClient.java @@ -0,0 +1,212 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobinterviewstages; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.jobinterviewstages.requests.JobInterviewStagesListRequest; +import com.merge.api.resources.ats.jobinterviewstages.requests.JobInterviewStagesRetrieveRequest; +import com.merge.api.resources.ats.types.JobInterviewStage; +import com.merge.api.resources.ats.types.PaginatedJobInterviewStageList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawJobInterviewStagesClient { + protected final ClientOptions clientOptions; + + public RawJobInterviewStagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of JobInterviewStage objects. + */ + public MergeApiHttpResponse list() { + return list(JobInterviewStagesListRequest.builder().build()); + } + + /** + * Returns a list of JobInterviewStage objects. + */ + public MergeApiHttpResponse list(JobInterviewStagesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of JobInterviewStage objects. + */ + public MergeApiHttpResponse list( + JobInterviewStagesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/job-interview-stages"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getJobId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "job_id", request.getJobId().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedJobInterviewStageList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a JobInterviewStage object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, JobInterviewStagesRetrieveRequest.builder().build()); + } + + /** + * Returns a JobInterviewStage object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, JobInterviewStagesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a JobInterviewStage object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, JobInterviewStagesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/job-interview-stages") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JobInterviewStage.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobinterviewstages/requests/JobInterviewStagesListRequest.java b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/requests/JobInterviewStagesListRequest.java index 16d84bd18..3499e0291 100644 --- a/src/main/java/com/merge/api/resources/ats/jobinterviewstages/requests/JobInterviewStagesListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/requests/JobInterviewStagesListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,14 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = JobInterviewStagesListRequest.Builder.class) public final class JobInterviewStagesListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -48,10 +50,10 @@ public final class JobInterviewStagesListRequest { private final Map additionalProperties; private JobInterviewStagesListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -61,10 +63,10 @@ private JobInterviewStagesListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -76,6 +78,14 @@ private JobInterviewStagesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -100,14 +110,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -184,10 +186,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(JobInterviewStagesListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -201,10 +203,10 @@ private boolean equalTo(JobInterviewStagesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -226,14 +228,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -256,10 +258,10 @@ public static final class Builder { private Builder() {} public Builder from(JobInterviewStagesListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -271,6 +273,22 @@ public Builder from(JobInterviewStagesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -304,17 +322,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -405,10 +412,10 @@ public Builder remoteId(String remoteId) { public JobInterviewStagesListRequest build() { return new JobInterviewStagesListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/jobinterviewstages/requests/JobInterviewStagesRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/requests/JobInterviewStagesRetrieveRequest.java index 123a55032..7e0562c83 100644 --- a/src/main/java/com/merge/api/resources/ats/jobinterviewstages/requests/JobInterviewStagesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/jobinterviewstages/requests/JobInterviewStagesRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = JobInterviewStagesRetrieveRequest.Builder.class) public final class JobInterviewStagesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private JobInterviewStagesRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private JobInterviewStagesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(JobInterviewStagesRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(JobInterviewStagesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,20 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public JobInterviewStagesRetrieveRequest build() { - return new JobInterviewStagesRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new JobInterviewStagesRetrieveRequest( + expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/jobpostings/AsyncJobPostingsClient.java b/src/main/java/com/merge/api/resources/ats/jobpostings/AsyncJobPostingsClient.java new file mode 100644 index 000000000..69cf3726b --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobpostings/AsyncJobPostingsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobpostings; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.jobpostings.requests.JobPostingsListRequest; +import com.merge.api.resources.ats.jobpostings.requests.JobPostingsRetrieveRequest; +import com.merge.api.resources.ats.types.JobPosting; +import com.merge.api.resources.ats.types.PaginatedJobPostingList; +import java.util.concurrent.CompletableFuture; + +public class AsyncJobPostingsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawJobPostingsClient rawClient; + + public AsyncJobPostingsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawJobPostingsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawJobPostingsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of JobPosting objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of JobPosting objects. + */ + public CompletableFuture list(JobPostingsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of JobPosting objects. + */ + public CompletableFuture list( + JobPostingsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a JobPosting object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a JobPosting object with the given id. + */ + public CompletableFuture retrieve(String id, JobPostingsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a JobPosting object with the given id. + */ + public CompletableFuture retrieve( + String id, JobPostingsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobpostings/AsyncRawJobPostingsClient.java b/src/main/java/com/merge/api/resources/ats/jobpostings/AsyncRawJobPostingsClient.java new file mode 100644 index 000000000..d9c112834 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobpostings/AsyncRawJobPostingsClient.java @@ -0,0 +1,243 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobpostings; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.jobpostings.requests.JobPostingsListRequest; +import com.merge.api.resources.ats.jobpostings.requests.JobPostingsRetrieveRequest; +import com.merge.api.resources.ats.types.JobPosting; +import com.merge.api.resources.ats.types.PaginatedJobPostingList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawJobPostingsClient { + protected final ClientOptions clientOptions; + + public AsyncRawJobPostingsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of JobPosting objects. + */ + public CompletableFuture> list() { + return list(JobPostingsListRequest.builder().build()); + } + + /** + * Returns a list of JobPosting objects. + */ + public CompletableFuture> list(JobPostingsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of JobPosting objects. + */ + public CompletableFuture> list( + JobPostingsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/job-postings"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedJobPostingList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a JobPosting object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, JobPostingsRetrieveRequest.builder().build()); + } + + /** + * Returns a JobPosting object with the given id. + */ + public CompletableFuture> retrieve(String id, JobPostingsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a JobPosting object with the given id. + */ + public CompletableFuture> retrieve( + String id, JobPostingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/job-postings") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JobPosting.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobpostings/JobPostingsClient.java b/src/main/java/com/merge/api/resources/ats/jobpostings/JobPostingsClient.java index c13e163eb..190494bd8 100644 --- a/src/main/java/com/merge/api/resources/ats/jobpostings/JobPostingsClient.java +++ b/src/main/java/com/merge/api/resources/ats/jobpostings/JobPostingsClient.java @@ -3,173 +3,69 @@ */ package com.merge.api.resources.ats.jobpostings; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.jobpostings.requests.JobPostingsListRequest; import com.merge.api.resources.ats.jobpostings.requests.JobPostingsRetrieveRequest; import com.merge.api.resources.ats.types.JobPosting; import com.merge.api.resources.ats.types.PaginatedJobPostingList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class JobPostingsClient { protected final ClientOptions clientOptions; + private final RawJobPostingsClient rawClient; + public JobPostingsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawJobPostingsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawJobPostingsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of JobPosting objects. */ public PaginatedJobPostingList list() { - return list(JobPostingsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of JobPosting objects. */ public PaginatedJobPostingList list(JobPostingsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of JobPosting objects. */ public PaginatedJobPostingList list(JobPostingsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/job-postings"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedJobPostingList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a JobPosting object with the given id. */ public JobPosting retrieve(String id) { - return retrieve(id, JobPostingsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a JobPosting object with the given id. */ public JobPosting retrieve(String id, JobPostingsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a JobPosting object with the given id. */ public JobPosting retrieve(String id, JobPostingsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/job-postings") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JobPosting.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/jobpostings/RawJobPostingsClient.java b/src/main/java/com/merge/api/resources/ats/jobpostings/RawJobPostingsClient.java new file mode 100644 index 000000000..b855f1015 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobpostings/RawJobPostingsClient.java @@ -0,0 +1,211 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobpostings; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.jobpostings.requests.JobPostingsListRequest; +import com.merge.api.resources.ats.jobpostings.requests.JobPostingsRetrieveRequest; +import com.merge.api.resources.ats.types.JobPosting; +import com.merge.api.resources.ats.types.PaginatedJobPostingList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawJobPostingsClient { + protected final ClientOptions clientOptions; + + public RawJobPostingsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of JobPosting objects. + */ + public MergeApiHttpResponse list() { + return list(JobPostingsListRequest.builder().build()); + } + + /** + * Returns a list of JobPosting objects. + */ + public MergeApiHttpResponse list(JobPostingsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of JobPosting objects. + */ + public MergeApiHttpResponse list( + JobPostingsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/job-postings"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedJobPostingList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a JobPosting object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, JobPostingsRetrieveRequest.builder().build()); + } + + /** + * Returns a JobPosting object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, JobPostingsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a JobPosting object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, JobPostingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/job-postings") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), JobPosting.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobpostings/requests/JobPostingsListRequest.java b/src/main/java/com/merge/api/resources/ats/jobpostings/requests/JobPostingsListRequest.java index faf4a43d0..128d2f888 100644 --- a/src/main/java/com/merge/api/resources/ats/jobpostings/requests/JobPostingsListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/jobpostings/requests/JobPostingsListRequest.java @@ -14,7 +14,9 @@ import com.merge.api.core.ObjectMappers; import com.merge.api.resources.ats.jobpostings.types.JobPostingsListRequestStatus; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,14 +24,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = JobPostingsListRequest.Builder.class) public final class JobPostingsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -49,10 +51,10 @@ public final class JobPostingsListRequest { private final Map additionalProperties; private JobPostingsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -62,10 +64,10 @@ private JobPostingsListRequest( Optional remoteId, Optional status, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -77,6 +79,14 @@ private JobPostingsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -101,14 +111,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -192,10 +194,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(JobPostingsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -209,10 +211,10 @@ private boolean equalTo(JobPostingsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -234,14 +236,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -264,10 +266,10 @@ public static final class Builder { private Builder() {} public Builder from(JobPostingsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -279,6 +281,22 @@ public Builder from(JobPostingsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -312,17 +330,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -413,10 +420,10 @@ public Builder status(JobPostingsListRequestStatus status) { public JobPostingsListRequest build() { return new JobPostingsListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/jobpostings/requests/JobPostingsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/jobpostings/requests/JobPostingsRetrieveRequest.java index 3d2ef206c..0222b238b 100644 --- a/src/main/java/com/merge/api/resources/ats/jobpostings/requests/JobPostingsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/jobpostings/requests/JobPostingsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = JobPostingsRetrieveRequest.Builder.class) public final class JobPostingsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private JobPostingsRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private JobPostingsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(JobPostingsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(JobPostingsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public JobPostingsRetrieveRequest build() { - return new JobPostingsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new JobPostingsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/jobs/AsyncJobsClient.java b/src/main/java/com/merge/api/resources/ats/jobs/AsyncJobsClient.java new file mode 100644 index 000000000..623ed2dd9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobs/AsyncJobsClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobs; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.jobs.requests.JobsListRequest; +import com.merge.api.resources.ats.jobs.requests.JobsRetrieveRequest; +import com.merge.api.resources.ats.jobs.requests.JobsScreeningQuestionsListRequest; +import com.merge.api.resources.ats.types.Job; +import com.merge.api.resources.ats.types.PaginatedJobList; +import com.merge.api.resources.ats.types.PaginatedScreeningQuestionList; +import java.util.concurrent.CompletableFuture; + +public class AsyncJobsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawJobsClient rawClient; + + public AsyncJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawJobsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawJobsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Job objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Job objects. + */ + public CompletableFuture list(JobsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Job objects. + */ + public CompletableFuture list(JobsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Job object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Job object with the given id. + */ + public CompletableFuture retrieve(String id, JobsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Job object with the given id. + */ + public CompletableFuture retrieve(String id, JobsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of ScreeningQuestion objects. + */ + public CompletableFuture screeningQuestionsList(String jobId) { + return this.rawClient.screeningQuestionsList(jobId).thenApply(response -> response.body()); + } + + /** + * Returns a list of ScreeningQuestion objects. + */ + public CompletableFuture screeningQuestionsList( + String jobId, JobsScreeningQuestionsListRequest request) { + return this.rawClient.screeningQuestionsList(jobId, request).thenApply(response -> response.body()); + } + + /** + * Returns a list of ScreeningQuestion objects. + */ + public CompletableFuture screeningQuestionsList( + String jobId, JobsScreeningQuestionsListRequest request, RequestOptions requestOptions) { + return this.rawClient + .screeningQuestionsList(jobId, request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobs/AsyncRawJobsClient.java b/src/main/java/com/merge/api/resources/ats/jobs/AsyncRawJobsClient.java new file mode 100644 index 000000000..0fb781c8d --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobs/AsyncRawJobsClient.java @@ -0,0 +1,370 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobs; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.jobs.requests.JobsListRequest; +import com.merge.api.resources.ats.jobs.requests.JobsRetrieveRequest; +import com.merge.api.resources.ats.jobs.requests.JobsScreeningQuestionsListRequest; +import com.merge.api.resources.ats.types.Job; +import com.merge.api.resources.ats.types.PaginatedJobList; +import com.merge.api.resources.ats.types.PaginatedScreeningQuestionList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawJobsClient { + protected final ClientOptions clientOptions; + + public AsyncRawJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Job objects. + */ + public CompletableFuture> list() { + return list(JobsListRequest.builder().build()); + } + + /** + * Returns a list of Job objects. + */ + public CompletableFuture> list(JobsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Job objects. + */ + public CompletableFuture> list( + JobsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/jobs"); + if (request.getCode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "code", request.getCode().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOffices().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offices", request.getOffices().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedJobList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Job object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, JobsRetrieveRequest.builder().build()); + } + + /** + * Returns a Job object with the given id. + */ + public CompletableFuture> retrieve(String id, JobsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Job object with the given id. + */ + public CompletableFuture> retrieve( + String id, JobsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/jobs") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Job.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of ScreeningQuestion objects. + */ + public CompletableFuture> screeningQuestionsList( + String jobId) { + return screeningQuestionsList( + jobId, JobsScreeningQuestionsListRequest.builder().build()); + } + + /** + * Returns a list of ScreeningQuestion objects. + */ + public CompletableFuture> screeningQuestionsList( + String jobId, JobsScreeningQuestionsListRequest request) { + return screeningQuestionsList(jobId, request, null); + } + + /** + * Returns a list of ScreeningQuestion objects. + */ + public CompletableFuture> screeningQuestionsList( + String jobId, JobsScreeningQuestionsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/jobs") + .addPathSegment(jobId) + .addPathSegments("screening-questions"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedScreeningQuestionList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobs/JobsClient.java b/src/main/java/com/merge/api/resources/ats/jobs/JobsClient.java index 01c7da75a..cd5febb15 100644 --- a/src/main/java/com/merge/api/resources/ats/jobs/JobsClient.java +++ b/src/main/java/com/merge/api/resources/ats/jobs/JobsClient.java @@ -3,10 +3,7 @@ */ package com.merge.api.resources.ats.jobs; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.jobs.requests.JobsListRequest; import com.merge.api.resources.ats.jobs.requests.JobsRetrieveRequest; @@ -14,193 +11,71 @@ import com.merge.api.resources.ats.types.Job; import com.merge.api.resources.ats.types.PaginatedJobList; import com.merge.api.resources.ats.types.PaginatedScreeningQuestionList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class JobsClient { protected final ClientOptions clientOptions; + private final RawJobsClient rawClient; + public JobsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawJobsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawJobsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Job objects. */ public PaginatedJobList list() { - return list(JobsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Job objects. */ public PaginatedJobList list(JobsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Job objects. */ public PaginatedJobList list(JobsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/jobs"); - if (request.getCode().isPresent()) { - httpUrl.addQueryParameter("code", request.getCode().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getOffices().isPresent()) { - httpUrl.addQueryParameter("offices", request.getOffices().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedJobList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Job object with the given id. */ public Job retrieve(String id) { - return retrieve(id, JobsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Job object with the given id. */ public Job retrieve(String id, JobsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Job object with the given id. */ public Job retrieve(String id, JobsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/jobs") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Job.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns a list of ScreeningQuestion objects. */ public PaginatedScreeningQuestionList screeningQuestionsList(String jobId) { - return screeningQuestionsList( - jobId, JobsScreeningQuestionsListRequest.builder().build()); + return this.rawClient.screeningQuestionsList(jobId).body(); } /** @@ -208,7 +83,7 @@ public PaginatedScreeningQuestionList screeningQuestionsList(String jobId) { */ public PaginatedScreeningQuestionList screeningQuestionsList( String jobId, JobsScreeningQuestionsListRequest request) { - return screeningQuestionsList(jobId, request, null); + return this.rawClient.screeningQuestionsList(jobId, request).body(); } /** @@ -216,56 +91,8 @@ public PaginatedScreeningQuestionList screeningQuestionsList( */ public PaginatedScreeningQuestionList screeningQuestionsList( String jobId, JobsScreeningQuestionsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/jobs") - .addPathSegment(jobId) - .addPathSegments("screening-questions"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedScreeningQuestionList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .screeningQuestionsList(jobId, request, requestOptions) + .body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/jobs/RawJobsClient.java b/src/main/java/com/merge/api/resources/ats/jobs/RawJobsClient.java new file mode 100644 index 000000000..7a894d2bf --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobs/RawJobsClient.java @@ -0,0 +1,323 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobs; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.jobs.requests.JobsListRequest; +import com.merge.api.resources.ats.jobs.requests.JobsRetrieveRequest; +import com.merge.api.resources.ats.jobs.requests.JobsScreeningQuestionsListRequest; +import com.merge.api.resources.ats.types.Job; +import com.merge.api.resources.ats.types.PaginatedJobList; +import com.merge.api.resources.ats.types.PaginatedScreeningQuestionList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawJobsClient { + protected final ClientOptions clientOptions; + + public RawJobsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Job objects. + */ + public MergeApiHttpResponse list() { + return list(JobsListRequest.builder().build()); + } + + /** + * Returns a list of Job objects. + */ + public MergeApiHttpResponse list(JobsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Job objects. + */ + public MergeApiHttpResponse list(JobsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/jobs"); + if (request.getCode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "code", request.getCode().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOffices().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "offices", request.getOffices().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedJobList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Job object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, JobsRetrieveRequest.builder().build()); + } + + /** + * Returns a Job object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, JobsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Job object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, JobsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/jobs") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Job.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of ScreeningQuestion objects. + */ + public MergeApiHttpResponse screeningQuestionsList(String jobId) { + return screeningQuestionsList( + jobId, JobsScreeningQuestionsListRequest.builder().build()); + } + + /** + * Returns a list of ScreeningQuestion objects. + */ + public MergeApiHttpResponse screeningQuestionsList( + String jobId, JobsScreeningQuestionsListRequest request) { + return screeningQuestionsList(jobId, request, null); + } + + /** + * Returns a list of ScreeningQuestion objects. + */ + public MergeApiHttpResponse screeningQuestionsList( + String jobId, JobsScreeningQuestionsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/jobs") + .addPathSegment(jobId) + .addPathSegments("screening-questions"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedScreeningQuestionList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsListRequest.java b/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsListRequest.java index ff90a1334..ec6a73810 100644 --- a/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsListRequest.java @@ -12,10 +12,12 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.jobs.types.JobsListRequestExpand; +import com.merge.api.resources.ats.jobs.types.JobsListRequestExpandItem; import com.merge.api.resources.ats.jobs.types.JobsListRequestStatus; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,6 +25,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = JobsListRequest.Builder.class) public final class JobsListRequest { + private final Optional> expand; + private final Optional code; private final Optional createdAfter; @@ -31,8 +35,6 @@ public final class JobsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -58,11 +60,11 @@ public final class JobsListRequest { private final Map additionalProperties; private JobsListRequest( + Optional> expand, Optional code, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -75,11 +77,11 @@ private JobsListRequest( Optional showEnumOrigins, Optional status, Map additionalProperties) { + this.expand = expand; this.code = code; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -94,6 +96,14 @@ private JobsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return jobs with this code. */ @@ -126,14 +136,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -241,11 +243,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(JobsListRequest other) { - return code.equals(other.code) + return expand.equals(other.expand) + && code.equals(other.code) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -262,11 +264,11 @@ private boolean equalTo(JobsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.code, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -291,6 +293,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional code = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -299,8 +303,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -329,11 +331,11 @@ public static final class Builder { private Builder() {} public Builder from(JobsListRequest other) { + expand(other.getExpand()); code(other.getCode()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -348,6 +350,22 @@ public Builder from(JobsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(JobsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "code", nulls = Nulls.SKIP) public Builder code(Optional code) { this.code = code; @@ -392,17 +410,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(JobsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -526,11 +533,11 @@ public Builder status(JobsListRequestStatus status) { public JobsListRequest build() { return new JobsListRequest( + expand, code, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsRetrieveRequest.java index b563005ed..f92ba7d48 100644 --- a/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.jobs.types.JobsRetrieveRequestExpand; +import com.merge.api.resources.ats.jobs.types.JobsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,10 +23,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = JobsRetrieveRequest.Builder.class) public final class JobsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -32,13 +36,15 @@ public final class JobsRetrieveRequest { private final Map additionalProperties; private JobsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -48,7 +54,7 @@ private JobsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -60,6 +66,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -90,13 +104,15 @@ public Map getAdditionalProperties() { private boolean equalTo(JobsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -110,10 +126,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -126,22 +144,28 @@ private Builder() {} public Builder from(JobsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(JobsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(JobsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -153,6 +177,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -177,7 +212,7 @@ public Builder showEnumOrigins(String showEnumOrigins) { public JobsRetrieveRequest build() { return new JobsRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsScreeningQuestionsListRequest.java b/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsScreeningQuestionsListRequest.java index 2711bfa23..ea74f54c4 100644 --- a/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsScreeningQuestionsListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/jobs/requests/JobsScreeningQuestionsListRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.jobs.types.JobsScreeningQuestionsListRequestExpand; +import com.merge.api.resources.ats.jobs.types.JobsScreeningQuestionsListRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,9 +23,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = JobsScreeningQuestionsListRequest.Builder.class) public final class JobsScreeningQuestionsListRequest { - private final Optional cursor; + private final Optional> expand; - private final Optional expand; + private final Optional cursor; private final Optional includeDeletedData; @@ -36,15 +38,15 @@ public final class JobsScreeningQuestionsListRequest { private final Map additionalProperties; private JobsScreeningQuestionsListRequest( + Optional> expand, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, Optional pageSize, Map additionalProperties) { - this.cursor = cursor; this.expand = expand; + this.cursor = cursor; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -53,19 +55,19 @@ private JobsScreeningQuestionsListRequest( } /** - * @return The pagination cursor value. + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; + @JsonProperty("expand") + public Optional> getExpand() { + return expand; } /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + * @return The pagination cursor value. */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; } /** @@ -112,8 +114,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(JobsScreeningQuestionsListRequest other) { - return cursor.equals(other.cursor) - && expand.equals(other.expand) + return expand.equals(other.expand) + && cursor.equals(other.cursor) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -123,8 +125,8 @@ private boolean equalTo(JobsScreeningQuestionsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.cursor, this.expand, + this.cursor, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -142,9 +144,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional cursor = Optional.empty(); + private Optional> expand = Optional.empty(); - private Optional expand = Optional.empty(); + private Optional cursor = Optional.empty(); private Optional includeDeletedData = Optional.empty(); @@ -160,8 +162,8 @@ public static final class Builder { private Builder() {} public Builder from(JobsScreeningQuestionsListRequest other) { - cursor(other.getCursor()); expand(other.getExpand()); + cursor(other.getCursor()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -169,25 +171,30 @@ public Builder from(JobsScreeningQuestionsListRequest other) { return this; } - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; return this; } - public Builder cursor(String cursor) { - this.cursor = Optional.ofNullable(cursor); + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; + public Builder expand(JobsScreeningQuestionsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); return this; } - public Builder expand(JobsScreeningQuestionsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); return this; } @@ -237,8 +244,8 @@ public Builder pageSize(Integer pageSize) { public JobsScreeningQuestionsListRequest build() { return new JobsScreeningQuestionsListRequest( - cursor, expand, + cursor, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/jobs/types/JobsListRequestExpand.java b/src/main/java/com/merge/api/resources/ats/jobs/types/JobsListRequestExpand.java deleted file mode 100644 index 71f91497f..000000000 --- a/src/main/java/com/merge/api/resources/ats/jobs/types/JobsListRequestExpand.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.jobs.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum JobsListRequestExpand { - DEPARTMENTS("departments"), - - DEPARTMENTS_HIRING_MANAGERS("departments,hiring_managers"), - - DEPARTMENTS_HIRING_MANAGERS_JOB_POSTINGS("departments,hiring_managers,job_postings"), - - DEPARTMENTS_HIRING_MANAGERS_JOB_POSTINGS_RECRUITERS("departments,hiring_managers,job_postings,recruiters"), - - DEPARTMENTS_HIRING_MANAGERS_RECRUITERS("departments,hiring_managers,recruiters"), - - DEPARTMENTS_JOB_POSTINGS("departments,job_postings"), - - DEPARTMENTS_JOB_POSTINGS_RECRUITERS("departments,job_postings,recruiters"), - - DEPARTMENTS_OFFICES("departments,offices"), - - DEPARTMENTS_OFFICES_HIRING_MANAGERS("departments,offices,hiring_managers"), - - DEPARTMENTS_OFFICES_HIRING_MANAGERS_JOB_POSTINGS("departments,offices,hiring_managers,job_postings"), - - DEPARTMENTS_OFFICES_HIRING_MANAGERS_JOB_POSTINGS_RECRUITERS( - "departments,offices,hiring_managers,job_postings,recruiters"), - - DEPARTMENTS_OFFICES_HIRING_MANAGERS_RECRUITERS("departments,offices,hiring_managers,recruiters"), - - DEPARTMENTS_OFFICES_JOB_POSTINGS("departments,offices,job_postings"), - - DEPARTMENTS_OFFICES_JOB_POSTINGS_RECRUITERS("departments,offices,job_postings,recruiters"), - - DEPARTMENTS_OFFICES_RECRUITERS("departments,offices,recruiters"), - - DEPARTMENTS_RECRUITERS("departments,recruiters"), - - HIRING_MANAGERS("hiring_managers"), - - HIRING_MANAGERS_JOB_POSTINGS("hiring_managers,job_postings"), - - HIRING_MANAGERS_JOB_POSTINGS_RECRUITERS("hiring_managers,job_postings,recruiters"), - - HIRING_MANAGERS_RECRUITERS("hiring_managers,recruiters"), - - JOB_POSTINGS("job_postings"), - - JOB_POSTINGS_RECRUITERS("job_postings,recruiters"), - - OFFICES("offices"), - - OFFICES_HIRING_MANAGERS("offices,hiring_managers"), - - OFFICES_HIRING_MANAGERS_JOB_POSTINGS("offices,hiring_managers,job_postings"), - - OFFICES_HIRING_MANAGERS_JOB_POSTINGS_RECRUITERS("offices,hiring_managers,job_postings,recruiters"), - - OFFICES_HIRING_MANAGERS_RECRUITERS("offices,hiring_managers,recruiters"), - - OFFICES_JOB_POSTINGS("offices,job_postings"), - - OFFICES_JOB_POSTINGS_RECRUITERS("offices,job_postings,recruiters"), - - OFFICES_RECRUITERS("offices,recruiters"), - - RECRUITERS("recruiters"); - - private final String value; - - JobsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/jobs/types/JobsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/jobs/types/JobsListRequestExpandItem.java new file mode 100644 index 000000000..27126431b --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobs/types/JobsListRequestExpandItem.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobs.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum JobsListRequestExpandItem { + DEPARTMENTS("departments"), + + HIRING_MANAGERS("hiring_managers"), + + JOB_POSTINGS("job_postings"), + + OFFICES("offices"), + + RECRUITERS("recruiters"); + + private final String value; + + JobsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobs/types/JobsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/ats/jobs/types/JobsRetrieveRequestExpand.java deleted file mode 100644 index a397f83f3..000000000 --- a/src/main/java/com/merge/api/resources/ats/jobs/types/JobsRetrieveRequestExpand.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.jobs.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum JobsRetrieveRequestExpand { - DEPARTMENTS("departments"), - - DEPARTMENTS_HIRING_MANAGERS("departments,hiring_managers"), - - DEPARTMENTS_HIRING_MANAGERS_JOB_POSTINGS("departments,hiring_managers,job_postings"), - - DEPARTMENTS_HIRING_MANAGERS_JOB_POSTINGS_RECRUITERS("departments,hiring_managers,job_postings,recruiters"), - - DEPARTMENTS_HIRING_MANAGERS_RECRUITERS("departments,hiring_managers,recruiters"), - - DEPARTMENTS_JOB_POSTINGS("departments,job_postings"), - - DEPARTMENTS_JOB_POSTINGS_RECRUITERS("departments,job_postings,recruiters"), - - DEPARTMENTS_OFFICES("departments,offices"), - - DEPARTMENTS_OFFICES_HIRING_MANAGERS("departments,offices,hiring_managers"), - - DEPARTMENTS_OFFICES_HIRING_MANAGERS_JOB_POSTINGS("departments,offices,hiring_managers,job_postings"), - - DEPARTMENTS_OFFICES_HIRING_MANAGERS_JOB_POSTINGS_RECRUITERS( - "departments,offices,hiring_managers,job_postings,recruiters"), - - DEPARTMENTS_OFFICES_HIRING_MANAGERS_RECRUITERS("departments,offices,hiring_managers,recruiters"), - - DEPARTMENTS_OFFICES_JOB_POSTINGS("departments,offices,job_postings"), - - DEPARTMENTS_OFFICES_JOB_POSTINGS_RECRUITERS("departments,offices,job_postings,recruiters"), - - DEPARTMENTS_OFFICES_RECRUITERS("departments,offices,recruiters"), - - DEPARTMENTS_RECRUITERS("departments,recruiters"), - - HIRING_MANAGERS("hiring_managers"), - - HIRING_MANAGERS_JOB_POSTINGS("hiring_managers,job_postings"), - - HIRING_MANAGERS_JOB_POSTINGS_RECRUITERS("hiring_managers,job_postings,recruiters"), - - HIRING_MANAGERS_RECRUITERS("hiring_managers,recruiters"), - - JOB_POSTINGS("job_postings"), - - JOB_POSTINGS_RECRUITERS("job_postings,recruiters"), - - OFFICES("offices"), - - OFFICES_HIRING_MANAGERS("offices,hiring_managers"), - - OFFICES_HIRING_MANAGERS_JOB_POSTINGS("offices,hiring_managers,job_postings"), - - OFFICES_HIRING_MANAGERS_JOB_POSTINGS_RECRUITERS("offices,hiring_managers,job_postings,recruiters"), - - OFFICES_HIRING_MANAGERS_RECRUITERS("offices,hiring_managers,recruiters"), - - OFFICES_JOB_POSTINGS("offices,job_postings"), - - OFFICES_JOB_POSTINGS_RECRUITERS("offices,job_postings,recruiters"), - - OFFICES_RECRUITERS("offices,recruiters"), - - RECRUITERS("recruiters"); - - private final String value; - - JobsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/jobs/types/JobsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/jobs/types/JobsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..18a300459 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobs/types/JobsRetrieveRequestExpandItem.java @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobs.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum JobsRetrieveRequestExpandItem { + DEPARTMENTS("departments"), + + HIRING_MANAGERS("hiring_managers"), + + JOB_POSTINGS("job_postings"), + + OFFICES("offices"), + + RECRUITERS("recruiters"); + + private final String value; + + JobsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/jobs/types/JobsScreeningQuestionsListRequestExpand.java b/src/main/java/com/merge/api/resources/ats/jobs/types/JobsScreeningQuestionsListRequestExpand.java deleted file mode 100644 index 572c4a298..000000000 --- a/src/main/java/com/merge/api/resources/ats/jobs/types/JobsScreeningQuestionsListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.jobs.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum JobsScreeningQuestionsListRequestExpand { - JOB("job"), - - OPTIONS("options"), - - OPTIONS_JOB("options,job"); - - private final String value; - - JobsScreeningQuestionsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/jobs/types/JobsScreeningQuestionsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/jobs/types/JobsScreeningQuestionsListRequestExpandItem.java new file mode 100644 index 000000000..0997bce70 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/jobs/types/JobsScreeningQuestionsListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.jobs.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum JobsScreeningQuestionsListRequestExpandItem { + JOB("job"), + + OPTIONS("options"); + + private final String value; + + JobsScreeningQuestionsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/linkedaccounts/AsyncLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/ats/linkedaccounts/AsyncLinkedAccountsClient.java new file mode 100644 index 000000000..255d20927 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/linkedaccounts/AsyncLinkedAccountsClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.linkedaccounts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.ats.types.PaginatedAccountDetailsAndActionsList; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkedAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkedAccountsClient rawClient; + + public AsyncLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkedAccountsClient withRawResponse() { + return this.rawClient; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list(LinkedAccountsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/linkedaccounts/AsyncRawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/ats/linkedaccounts/AsyncRawLinkedAccountsClient.java new file mode 100644 index 000000000..a7062fba5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/linkedaccounts/AsyncRawLinkedAccountsClient.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.ats.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/linkedaccounts/LinkedAccountsClient.java b/src/main/java/com/merge/api/resources/ats/linkedaccounts/LinkedAccountsClient.java index cb0498dd7..a641e44f7 100644 --- a/src/main/java/com/merge/api/resources/ats/linkedaccounts/LinkedAccountsClient.java +++ b/src/main/java/com/merge/api/resources/ats/linkedaccounts/LinkedAccountsClient.java @@ -3,40 +3,40 @@ */ package com.merge.api.resources.ats.linkedaccounts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.linkedaccounts.requests.LinkedAccountsListRequest; import com.merge.api.resources.ats.types.PaginatedAccountDetailsAndActionsList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkedAccountsClient { protected final ClientOptions clientOptions; + private final RawLinkedAccountsClient rawClient; + public LinkedAccountsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkedAccountsClient withRawResponse() { + return this.rawClient; } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list() { - return list(LinkedAccountsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** @@ -44,80 +44,6 @@ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest requ */ public PaginatedAccountDetailsAndActionsList list( LinkedAccountsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/linked-accounts"); - if (request.getCategory().isPresent()) { - httpUrl.addQueryParameter("category", request.getCategory().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndUserEmailAddress().isPresent()) { - httpUrl.addQueryParameter( - "end_user_email_address", request.getEndUserEmailAddress().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getEndUserOriginId().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_id", request.getEndUserOriginId().get()); - } - if (request.getEndUserOriginIds().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_ids", request.getEndUserOriginIds().get()); - } - if (request.getId().isPresent()) { - httpUrl.addQueryParameter("id", request.getId().get()); - } - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getIncludeDuplicates().isPresent()) { - httpUrl.addQueryParameter( - "include_duplicates", request.getIncludeDuplicates().get().toString()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getIsTestAccount().isPresent()) { - httpUrl.addQueryParameter( - "is_test_account", request.getIsTestAccount().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedAccountDetailsAndActionsList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/linkedaccounts/RawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/ats/linkedaccounts/RawLinkedAccountsClient.java new file mode 100644 index 000000000..aa5d58fdb --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/linkedaccounts/RawLinkedAccountsClient.java @@ -0,0 +1,143 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.ats.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public RawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list(LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/linktoken/AsyncLinkTokenClient.java b/src/main/java/com/merge/api/resources/ats/linktoken/AsyncLinkTokenClient.java new file mode 100644 index 000000000..b1fbb67c9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/linktoken/AsyncLinkTokenClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.linktoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.ats.types.LinkToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkTokenClient rawClient; + + public AsyncLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/linktoken/AsyncRawLinkTokenClient.java b/src/main/java/com/merge/api/resources/ats/linktoken/AsyncRawLinkTokenClient.java new file mode 100644 index 000000000..176376843 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/linktoken/AsyncRawLinkTokenClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.ats.types.LinkToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create( + EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/linktoken/LinkTokenClient.java b/src/main/java/com/merge/api/resources/ats/linktoken/LinkTokenClient.java index cd585031b..344b4a14a 100644 --- a/src/main/java/com/merge/api/resources/ats/linktoken/LinkTokenClient.java +++ b/src/main/java/com/merge/api/resources/ats/linktoken/LinkTokenClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.ats.linktoken; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.linktoken.requests.EndUserDetailsRequest; import com.merge.api.resources.ats.types.LinkToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkTokenClient { protected final ClientOptions clientOptions; + private final RawLinkTokenClient rawClient; + public LinkTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkTokenClient withRawResponse() { + return this.rawClient; } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/link-token") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/linktoken/RawLinkTokenClient.java b/src/main/java/com/merge/api/resources/ats/linktoken/RawLinkTokenClient.java new file mode 100644 index 000000000..d62160089 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/linktoken/RawLinkTokenClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.ats.types.LinkToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkTokenClient { + protected final ClientOptions clientOptions; + + public RawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/offers/AsyncOffersClient.java b/src/main/java/com/merge/api/resources/ats/offers/AsyncOffersClient.java new file mode 100644 index 000000000..593d84371 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/offers/AsyncOffersClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.offers; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.offers.requests.OffersListRequest; +import com.merge.api.resources.ats.offers.requests.OffersRetrieveRequest; +import com.merge.api.resources.ats.types.Offer; +import com.merge.api.resources.ats.types.PaginatedOfferList; +import java.util.concurrent.CompletableFuture; + +public class AsyncOffersClient { + protected final ClientOptions clientOptions; + + private final AsyncRawOffersClient rawClient; + + public AsyncOffersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawOffersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawOffersClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Offer objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Offer objects. + */ + public CompletableFuture list(OffersListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Offer objects. + */ + public CompletableFuture list(OffersListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Offer object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Offer object with the given id. + */ + public CompletableFuture retrieve(String id, OffersRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Offer object with the given id. + */ + public CompletableFuture retrieve(String id, OffersRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/offers/AsyncRawOffersClient.java b/src/main/java/com/merge/api/resources/ats/offers/AsyncRawOffersClient.java new file mode 100644 index 000000000..160d69b16 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/offers/AsyncRawOffersClient.java @@ -0,0 +1,261 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.offers; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.offers.requests.OffersListRequest; +import com.merge.api.resources.ats.offers.requests.OffersRetrieveRequest; +import com.merge.api.resources.ats.types.Offer; +import com.merge.api.resources.ats.types.PaginatedOfferList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawOffersClient { + protected final ClientOptions clientOptions; + + public AsyncRawOffersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Offer objects. + */ + public CompletableFuture> list() { + return list(OffersListRequest.builder().build()); + } + + /** + * Returns a list of Offer objects. + */ + public CompletableFuture> list(OffersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Offer objects. + */ + public CompletableFuture> list( + OffersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/offers"); + if (request.getApplicationId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "application_id", request.getApplicationId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCreatorId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "creator_id", request.getCreatorId().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedOfferList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Offer object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, OffersRetrieveRequest.builder().build()); + } + + /** + * Returns an Offer object with the given id. + */ + public CompletableFuture> retrieve(String id, OffersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Offer object with the given id. + */ + public CompletableFuture> retrieve( + String id, OffersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/offers") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Offer.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/offers/OffersClient.java b/src/main/java/com/merge/api/resources/ats/offers/OffersClient.java index c50c482e8..54dc1c918 100644 --- a/src/main/java/com/merge/api/resources/ats/offers/OffersClient.java +++ b/src/main/java/com/merge/api/resources/ats/offers/OffersClient.java @@ -3,191 +3,69 @@ */ package com.merge.api.resources.ats.offers; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.offers.requests.OffersListRequest; import com.merge.api.resources.ats.offers.requests.OffersRetrieveRequest; import com.merge.api.resources.ats.types.Offer; import com.merge.api.resources.ats.types.PaginatedOfferList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class OffersClient { protected final ClientOptions clientOptions; + private final RawOffersClient rawClient; + public OffersClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawOffersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawOffersClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Offer objects. */ public PaginatedOfferList list() { - return list(OffersListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Offer objects. */ public PaginatedOfferList list(OffersListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Offer objects. */ public PaginatedOfferList list(OffersListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/offers"); - if (request.getApplicationId().isPresent()) { - httpUrl.addQueryParameter( - "application_id", request.getApplicationId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCreatorId().isPresent()) { - httpUrl.addQueryParameter("creator_id", request.getCreatorId().get()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedOfferList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an Offer object with the given id. */ public Offer retrieve(String id) { - return retrieve(id, OffersRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Offer object with the given id. */ public Offer retrieve(String id, OffersRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Offer object with the given id. */ public Offer retrieve(String id, OffersRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/offers") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Offer.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/offers/RawOffersClient.java b/src/main/java/com/merge/api/resources/ats/offers/RawOffersClient.java new file mode 100644 index 000000000..dac1e31f9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/offers/RawOffersClient.java @@ -0,0 +1,229 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.offers; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.offers.requests.OffersListRequest; +import com.merge.api.resources.ats.offers.requests.OffersRetrieveRequest; +import com.merge.api.resources.ats.types.Offer; +import com.merge.api.resources.ats.types.PaginatedOfferList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawOffersClient { + protected final ClientOptions clientOptions; + + public RawOffersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Offer objects. + */ + public MergeApiHttpResponse list() { + return list(OffersListRequest.builder().build()); + } + + /** + * Returns a list of Offer objects. + */ + public MergeApiHttpResponse list(OffersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Offer objects. + */ + public MergeApiHttpResponse list(OffersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/offers"); + if (request.getApplicationId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "application_id", request.getApplicationId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCreatorId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "creator_id", request.getCreatorId().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedOfferList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Offer object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, OffersRetrieveRequest.builder().build()); + } + + /** + * Returns an Offer object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, OffersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Offer object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, OffersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/offers") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Offer.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/offers/requests/OffersListRequest.java b/src/main/java/com/merge/api/resources/ats/offers/requests/OffersListRequest.java index eccd03295..ff9806280 100644 --- a/src/main/java/com/merge/api/resources/ats/offers/requests/OffersListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/offers/requests/OffersListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.offers.types.OffersListRequestExpand; +import com.merge.api.resources.ats.offers.types.OffersListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = OffersListRequest.Builder.class) public final class OffersListRequest { + private final Optional> expand; + private final Optional applicationId; private final Optional createdAfter; @@ -32,8 +36,6 @@ public final class OffersListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -55,12 +57,12 @@ public final class OffersListRequest { private final Map additionalProperties; private OffersListRequest( + Optional> expand, Optional applicationId, Optional createdAfter, Optional createdBefore, Optional creatorId, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -71,12 +73,12 @@ private OffersListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.applicationId = applicationId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.creatorId = creatorId; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -89,6 +91,14 @@ private OffersListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return offers for this application. */ @@ -129,14 +139,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -221,12 +223,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(OffersListRequest other) { - return applicationId.equals(other.applicationId) + return expand.equals(other.expand) + && applicationId.equals(other.applicationId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && creatorId.equals(other.creatorId) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -241,12 +243,12 @@ private boolean equalTo(OffersListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.applicationId, this.createdAfter, this.createdBefore, this.creatorId, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -269,6 +271,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional applicationId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -279,8 +283,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -305,12 +307,12 @@ public static final class Builder { private Builder() {} public Builder from(OffersListRequest other) { + expand(other.getExpand()); applicationId(other.getApplicationId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); creatorId(other.getCreatorId()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -323,6 +325,22 @@ public Builder from(OffersListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(OffersListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "application_id", nulls = Nulls.SKIP) public Builder applicationId(Optional applicationId) { this.applicationId = applicationId; @@ -378,17 +396,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(OffersListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -490,12 +497,12 @@ public Builder showEnumOrigins(String showEnumOrigins) { public OffersListRequest build() { return new OffersListRequest( + expand, applicationId, createdAfter, createdBefore, creatorId, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/offers/requests/OffersRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/offers/requests/OffersRetrieveRequest.java index ecdd2a680..d8584970b 100644 --- a/src/main/java/com/merge/api/resources/ats/offers/requests/OffersRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/offers/requests/OffersRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.offers.types.OffersRetrieveRequestExpand; +import com.merge.api.resources.ats.offers.types.OffersRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,10 +23,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = OffersRetrieveRequest.Builder.class) public final class OffersRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -32,13 +36,15 @@ public final class OffersRetrieveRequest { private final Map additionalProperties; private OffersRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -48,7 +54,7 @@ private OffersRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -60,6 +66,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -90,13 +104,15 @@ public Map getAdditionalProperties() { private boolean equalTo(OffersRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -110,10 +126,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -126,22 +144,28 @@ private Builder() {} public Builder from(OffersRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(OffersRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(OffersRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -153,6 +177,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -177,7 +212,7 @@ public Builder showEnumOrigins(String showEnumOrigins) { public OffersRetrieveRequest build() { return new OffersRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/offers/types/OffersListRequestExpand.java b/src/main/java/com/merge/api/resources/ats/offers/types/OffersListRequestExpand.java deleted file mode 100644 index 29f725d71..000000000 --- a/src/main/java/com/merge/api/resources/ats/offers/types/OffersListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.offers.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum OffersListRequestExpand { - APPLICATION("application"), - - APPLICATION_CREATOR("application,creator"), - - CREATOR("creator"); - - private final String value; - - OffersListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/offers/types/OffersListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/offers/types/OffersListRequestExpandItem.java new file mode 100644 index 000000000..0165ae777 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/offers/types/OffersListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.offers.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum OffersListRequestExpandItem { + APPLICATION("application"), + + CREATOR("creator"); + + private final String value; + + OffersListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/offers/types/OffersRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/ats/offers/types/OffersRetrieveRequestExpand.java deleted file mode 100644 index abfa2da2b..000000000 --- a/src/main/java/com/merge/api/resources/ats/offers/types/OffersRetrieveRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.offers.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum OffersRetrieveRequestExpand { - APPLICATION("application"), - - APPLICATION_CREATOR("application,creator"), - - CREATOR("creator"); - - private final String value; - - OffersRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/offers/types/OffersRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/offers/types/OffersRetrieveRequestExpandItem.java new file mode 100644 index 000000000..0ccca80d3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/offers/types/OffersRetrieveRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.offers.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum OffersRetrieveRequestExpandItem { + APPLICATION("application"), + + CREATOR("creator"); + + private final String value; + + OffersRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/offices/AsyncOfficesClient.java b/src/main/java/com/merge/api/resources/ats/offices/AsyncOfficesClient.java new file mode 100644 index 000000000..a2e435678 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/offices/AsyncOfficesClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.offices; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.offices.requests.OfficesListRequest; +import com.merge.api.resources.ats.offices.requests.OfficesRetrieveRequest; +import com.merge.api.resources.ats.types.Office; +import com.merge.api.resources.ats.types.PaginatedOfficeList; +import java.util.concurrent.CompletableFuture; + +public class AsyncOfficesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawOfficesClient rawClient; + + public AsyncOfficesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawOfficesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawOfficesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Office objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Office objects. + */ + public CompletableFuture list(OfficesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Office objects. + */ + public CompletableFuture list(OfficesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Office object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Office object with the given id. + */ + public CompletableFuture retrieve(String id, OfficesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Office object with the given id. + */ + public CompletableFuture retrieve( + String id, OfficesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/offices/AsyncRawOfficesClient.java b/src/main/java/com/merge/api/resources/ats/offices/AsyncRawOfficesClient.java new file mode 100644 index 000000000..9d9b8daa0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/offices/AsyncRawOfficesClient.java @@ -0,0 +1,229 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.offices; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.offices.requests.OfficesListRequest; +import com.merge.api.resources.ats.offices.requests.OfficesRetrieveRequest; +import com.merge.api.resources.ats.types.Office; +import com.merge.api.resources.ats.types.PaginatedOfficeList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawOfficesClient { + protected final ClientOptions clientOptions; + + public AsyncRawOfficesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Office objects. + */ + public CompletableFuture> list() { + return list(OfficesListRequest.builder().build()); + } + + /** + * Returns a list of Office objects. + */ + public CompletableFuture> list(OfficesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Office objects. + */ + public CompletableFuture> list( + OfficesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/offices"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedOfficeList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Office object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, OfficesRetrieveRequest.builder().build()); + } + + /** + * Returns an Office object with the given id. + */ + public CompletableFuture> retrieve(String id, OfficesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Office object with the given id. + */ + public CompletableFuture> retrieve( + String id, OfficesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/offices") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Office.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/offices/OfficesClient.java b/src/main/java/com/merge/api/resources/ats/offices/OfficesClient.java index 6a5320785..295a5c1ee 100644 --- a/src/main/java/com/merge/api/resources/ats/offices/OfficesClient.java +++ b/src/main/java/com/merge/api/resources/ats/offices/OfficesClient.java @@ -3,164 +3,69 @@ */ package com.merge.api.resources.ats.offices; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.offices.requests.OfficesListRequest; import com.merge.api.resources.ats.offices.requests.OfficesRetrieveRequest; import com.merge.api.resources.ats.types.Office; import com.merge.api.resources.ats.types.PaginatedOfficeList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class OfficesClient { protected final ClientOptions clientOptions; + private final RawOfficesClient rawClient; + public OfficesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawOfficesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawOfficesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Office objects. */ public PaginatedOfficeList list() { - return list(OfficesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Office objects. */ public PaginatedOfficeList list(OfficesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Office objects. */ public PaginatedOfficeList list(OfficesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/offices"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedOfficeList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an Office object with the given id. */ public Office retrieve(String id) { - return retrieve(id, OfficesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Office object with the given id. */ public Office retrieve(String id, OfficesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Office object with the given id. */ public Office retrieve(String id, OfficesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/offices") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Office.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/offices/RawOfficesClient.java b/src/main/java/com/merge/api/resources/ats/offices/RawOfficesClient.java new file mode 100644 index 000000000..6237d66c6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/offices/RawOfficesClient.java @@ -0,0 +1,198 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.offices; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.offices.requests.OfficesListRequest; +import com.merge.api.resources.ats.offices.requests.OfficesRetrieveRequest; +import com.merge.api.resources.ats.types.Office; +import com.merge.api.resources.ats.types.PaginatedOfficeList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawOfficesClient { + protected final ClientOptions clientOptions; + + public RawOfficesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Office objects. + */ + public MergeApiHttpResponse list() { + return list(OfficesListRequest.builder().build()); + } + + /** + * Returns a list of Office objects. + */ + public MergeApiHttpResponse list(OfficesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Office objects. + */ + public MergeApiHttpResponse list(OfficesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/offices"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedOfficeList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Office object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, OfficesRetrieveRequest.builder().build()); + } + + /** + * Returns an Office object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, OfficesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Office object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, OfficesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/offices") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Office.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/offices/requests/OfficesRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/offices/requests/OfficesRetrieveRequest.java index 82a8d0234..dd5ec6b79 100644 --- a/src/main/java/com/merge/api/resources/ats/offices/requests/OfficesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/offices/requests/OfficesRetrieveRequest.java @@ -22,10 +22,16 @@ public final class OfficesRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private OfficesRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private OfficesRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(OfficesRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(OfficesRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public OfficesRetrieveRequest build() { - return new OfficesRetrieveRequest(includeRemoteData, additionalProperties); + return new OfficesRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/passthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/ats/passthrough/AsyncPassthroughClient.java new file mode 100644 index 000000000..ebf7a6bd9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/passthrough/AsyncPassthroughClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.passthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.DataPassthroughRequest; +import com.merge.api.resources.ats.types.RemoteResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPassthroughClient rawClient; + + public AsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/passthrough/AsyncRawPassthroughClient.java b/src/main/java/com/merge/api/resources/ats/passthrough/AsyncRawPassthroughClient.java new file mode 100644 index 000000000..f809fe3cb --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/passthrough/AsyncRawPassthroughClient.java @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.DataPassthroughRequest; +import com.merge.api.resources.ats.types.RemoteResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/passthrough/PassthroughClient.java b/src/main/java/com/merge/api/resources/ats/passthrough/PassthroughClient.java index 1362268a6..c5bf0e03a 100644 --- a/src/main/java/com/merge/api/resources/ats/passthrough/PassthroughClient.java +++ b/src/main/java/com/merge/api/resources/ats/passthrough/PassthroughClient.java @@ -3,75 +3,39 @@ */ package com.merge.api.resources.ats.passthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.types.DataPassthroughRequest; import com.merge.api.resources.ats.types.RemoteResponse; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PassthroughClient { protected final ClientOptions clientOptions; + private final RawPassthroughClient rawClient; + public PassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPassthroughClient withRawResponse() { + return this.rawClient; } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/passthrough/RawPassthroughClient.java b/src/main/java/com/merge/api/resources/ats/passthrough/RawPassthroughClient.java new file mode 100644 index 000000000..67ef9b649 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/passthrough/RawPassthroughClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.DataPassthroughRequest; +import com.merge.api.resources.ats.types.RemoteResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPassthroughClient { + protected final ClientOptions clientOptions; + + public RawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/regeneratekey/AsyncRawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/ats/regeneratekey/AsyncRawRegenerateKeyClient.java new file mode 100644 index 000000000..538d4ab2f --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/regeneratekey/AsyncRawRegenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.ats.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/regeneratekey/AsyncRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/ats/regeneratekey/AsyncRegenerateKeyClient.java new file mode 100644 index 000000000..137d498a8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/regeneratekey/AsyncRegenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.regeneratekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.ats.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncRegenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawRegenerateKeyClient rawClient; + + public AsyncRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawRegenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/regeneratekey/RawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/ats/regeneratekey/RawRegenerateKeyClient.java new file mode 100644 index 000000000..76b484e15 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/regeneratekey/RawRegenerateKeyClient.java @@ -0,0 +1,82 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.ats.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/regeneratekey/RegenerateKeyClient.java b/src/main/java/com/merge/api/resources/ats/regeneratekey/RegenerateKeyClient.java index 90a7a9e6f..9f6dffa10 100644 --- a/src/main/java/com/merge/api/resources/ats/regeneratekey/RegenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/ats/regeneratekey/RegenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.ats.regeneratekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.regeneratekey.requests.RemoteKeyForRegenerationRequest; import com.merge.api.resources.ats.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class RegenerateKeyClient { protected final ClientOptions clientOptions; + private final RawRegenerateKeyClient rawClient; + public RegenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawRegenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/regenerate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/rejectreasons/AsyncRawRejectReasonsClient.java b/src/main/java/com/merge/api/resources/ats/rejectreasons/AsyncRawRejectReasonsClient.java new file mode 100644 index 000000000..656c4cdf2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/rejectreasons/AsyncRawRejectReasonsClient.java @@ -0,0 +1,232 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.rejectreasons; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.rejectreasons.requests.RejectReasonsListRequest; +import com.merge.api.resources.ats.rejectreasons.requests.RejectReasonsRetrieveRequest; +import com.merge.api.resources.ats.types.PaginatedRejectReasonList; +import com.merge.api.resources.ats.types.RejectReason; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawRejectReasonsClient { + protected final ClientOptions clientOptions; + + public AsyncRawRejectReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of RejectReason objects. + */ + public CompletableFuture> list() { + return list(RejectReasonsListRequest.builder().build()); + } + + /** + * Returns a list of RejectReason objects. + */ + public CompletableFuture> list(RejectReasonsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of RejectReason objects. + */ + public CompletableFuture> list( + RejectReasonsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/reject-reasons"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRejectReasonList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a RejectReason object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, RejectReasonsRetrieveRequest.builder().build()); + } + + /** + * Returns a RejectReason object with the given id. + */ + public CompletableFuture> retrieve( + String id, RejectReasonsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a RejectReason object with the given id. + */ + public CompletableFuture> retrieve( + String id, RejectReasonsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/reject-reasons") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RejectReason.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/rejectreasons/AsyncRejectReasonsClient.java b/src/main/java/com/merge/api/resources/ats/rejectreasons/AsyncRejectReasonsClient.java new file mode 100644 index 000000000..501bfc1bb --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/rejectreasons/AsyncRejectReasonsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.rejectreasons; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.rejectreasons.requests.RejectReasonsListRequest; +import com.merge.api.resources.ats.rejectreasons.requests.RejectReasonsRetrieveRequest; +import com.merge.api.resources.ats.types.PaginatedRejectReasonList; +import com.merge.api.resources.ats.types.RejectReason; +import java.util.concurrent.CompletableFuture; + +public class AsyncRejectReasonsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawRejectReasonsClient rawClient; + + public AsyncRejectReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawRejectReasonsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawRejectReasonsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of RejectReason objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of RejectReason objects. + */ + public CompletableFuture list(RejectReasonsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RejectReason objects. + */ + public CompletableFuture list( + RejectReasonsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a RejectReason object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a RejectReason object with the given id. + */ + public CompletableFuture retrieve(String id, RejectReasonsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a RejectReason object with the given id. + */ + public CompletableFuture retrieve( + String id, RejectReasonsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/rejectreasons/RawRejectReasonsClient.java b/src/main/java/com/merge/api/resources/ats/rejectreasons/RawRejectReasonsClient.java new file mode 100644 index 000000000..7d7a7a404 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/rejectreasons/RawRejectReasonsClient.java @@ -0,0 +1,199 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.rejectreasons; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.rejectreasons.requests.RejectReasonsListRequest; +import com.merge.api.resources.ats.rejectreasons.requests.RejectReasonsRetrieveRequest; +import com.merge.api.resources.ats.types.PaginatedRejectReasonList; +import com.merge.api.resources.ats.types.RejectReason; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawRejectReasonsClient { + protected final ClientOptions clientOptions; + + public RawRejectReasonsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of RejectReason objects. + */ + public MergeApiHttpResponse list() { + return list(RejectReasonsListRequest.builder().build()); + } + + /** + * Returns a list of RejectReason objects. + */ + public MergeApiHttpResponse list(RejectReasonsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of RejectReason objects. + */ + public MergeApiHttpResponse list( + RejectReasonsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/reject-reasons"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRejectReasonList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a RejectReason object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, RejectReasonsRetrieveRequest.builder().build()); + } + + /** + * Returns a RejectReason object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, RejectReasonsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a RejectReason object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, RejectReasonsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/reject-reasons") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RejectReason.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/rejectreasons/RejectReasonsClient.java b/src/main/java/com/merge/api/resources/ats/rejectreasons/RejectReasonsClient.java index 466913eca..632842e13 100644 --- a/src/main/java/com/merge/api/resources/ats/rejectreasons/RejectReasonsClient.java +++ b/src/main/java/com/merge/api/resources/ats/rejectreasons/RejectReasonsClient.java @@ -3,164 +3,69 @@ */ package com.merge.api.resources.ats.rejectreasons; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.rejectreasons.requests.RejectReasonsListRequest; import com.merge.api.resources.ats.rejectreasons.requests.RejectReasonsRetrieveRequest; import com.merge.api.resources.ats.types.PaginatedRejectReasonList; import com.merge.api.resources.ats.types.RejectReason; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class RejectReasonsClient { protected final ClientOptions clientOptions; + private final RawRejectReasonsClient rawClient; + public RejectReasonsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawRejectReasonsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawRejectReasonsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of RejectReason objects. */ public PaginatedRejectReasonList list() { - return list(RejectReasonsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of RejectReason objects. */ public PaginatedRejectReasonList list(RejectReasonsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of RejectReason objects. */ public PaginatedRejectReasonList list(RejectReasonsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/reject-reasons"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRejectReasonList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a RejectReason object with the given id. */ public RejectReason retrieve(String id) { - return retrieve(id, RejectReasonsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a RejectReason object with the given id. */ public RejectReason retrieve(String id, RejectReasonsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a RejectReason object with the given id. */ public RejectReason retrieve(String id, RejectReasonsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/reject-reasons") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RejectReason.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/rejectreasons/requests/RejectReasonsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/rejectreasons/requests/RejectReasonsRetrieveRequest.java index 20d543488..ef1a0467b 100644 --- a/src/main/java/com/merge/api/resources/ats/rejectreasons/requests/RejectReasonsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/rejectreasons/requests/RejectReasonsRetrieveRequest.java @@ -22,11 +22,16 @@ public final class RejectReasonsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private RejectReasonsRetrieveRequest( - Optional includeRemoteData, Map additionalProperties) { + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -38,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -50,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(RejectReasonsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -71,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -78,6 +93,7 @@ private Builder() {} public Builder from(RejectReasonsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -92,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public RejectReasonsRetrieveRequest build() { - return new RejectReasonsRetrieveRequest(includeRemoteData, additionalProperties); + return new RejectReasonsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/scopes/AsyncRawScopesClient.java b/src/main/java/com/merge/api/resources/ats/scopes/AsyncRawScopesClient.java new file mode 100644 index 000000000..8a9ee65fd --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/scopes/AsyncRawScopesClient.java @@ -0,0 +1,217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.ats.types.CommonModelScopeApi; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawScopesClient { + protected final ClientOptions clientOptions; + + public AsyncRawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/scopes/AsyncScopesClient.java b/src/main/java/com/merge/api/resources/ats/scopes/AsyncScopesClient.java new file mode 100644 index 000000000..478b28217 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/scopes/AsyncScopesClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.scopes; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.ats.types.CommonModelScopeApi; +import java.util.concurrent.CompletableFuture; + +public class AsyncScopesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawScopesClient rawClient; + + public AsyncScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawScopesClient withRawResponse() { + return this.rawClient; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve() { + return this.rawClient.defaultScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.defaultScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve() { + return this.rawClient.linkedAccountScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return this.rawClient.linkedAccountScopesCreate(request).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/scopes/RawScopesClient.java b/src/main/java/com/merge/api/resources/ats/scopes/RawScopesClient.java new file mode 100644 index 000000000..a8321f874 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/scopes/RawScopesClient.java @@ -0,0 +1,172 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.ats.types.CommonModelScopeApi; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawScopesClient { + protected final ClientOptions clientOptions; + + public RawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/scopes/ScopesClient.java b/src/main/java/com/merge/api/resources/ats/scopes/ScopesClient.java index 9d60d9130..269c2e71b 100644 --- a/src/main/java/com/merge/api/resources/ats/scopes/ScopesClient.java +++ b/src/main/java/com/merge/api/resources/ats/scopes/ScopesClient.java @@ -3,118 +3,61 @@ */ package com.merge.api.resources.ats.scopes; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; import com.merge.api.resources.ats.types.CommonModelScopeApi; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ScopesClient { protected final ClientOptions clientOptions; + private final RawScopesClient rawClient; + public ScopesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawScopesClient withRawResponse() { + return this.rawClient; } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve() { - return defaultScopesRetrieve(null); + return this.rawClient.defaultScopesRetrieve().body(); } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/default-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.defaultScopesRetrieve(requestOptions).body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve() { - return linkedAccountScopesRetrieve(null); + return this.rawClient.linkedAccountScopesRetrieve().body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/linked-account-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).body(); } /** * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more */ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelScopeDeserializerRequest request) { - return linkedAccountScopesCreate(request, null); + return this.rawClient.linkedAccountScopesCreate(request).body(); } /** @@ -122,40 +65,6 @@ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelSco */ public CommonModelScopeApi linkedAccountScopesCreate( LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/linked-account-scopes") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/scorecards/AsyncRawScorecardsClient.java b/src/main/java/com/merge/api/resources/ats/scorecards/AsyncRawScorecardsClient.java new file mode 100644 index 000000000..6493369d2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/scorecards/AsyncRawScorecardsClient.java @@ -0,0 +1,266 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.scorecards; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.scorecards.requests.ScorecardsListRequest; +import com.merge.api.resources.ats.scorecards.requests.ScorecardsRetrieveRequest; +import com.merge.api.resources.ats.types.PaginatedScorecardList; +import com.merge.api.resources.ats.types.Scorecard; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawScorecardsClient { + protected final ClientOptions clientOptions; + + public AsyncRawScorecardsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Scorecard objects. + */ + public CompletableFuture> list() { + return list(ScorecardsListRequest.builder().build()); + } + + /** + * Returns a list of Scorecard objects. + */ + public CompletableFuture> list(ScorecardsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Scorecard objects. + */ + public CompletableFuture> list( + ScorecardsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/scorecards"); + if (request.getApplicationId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "application_id", request.getApplicationId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getInterviewId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "interview_id", request.getInterviewId().get(), false); + } + if (request.getInterviewerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "interviewer_id", request.getInterviewerId().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedScorecardList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Scorecard object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, ScorecardsRetrieveRequest.builder().build()); + } + + /** + * Returns a Scorecard object with the given id. + */ + public CompletableFuture> retrieve(String id, ScorecardsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Scorecard object with the given id. + */ + public CompletableFuture> retrieve( + String id, ScorecardsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/scorecards") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Scorecard.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/scorecards/AsyncScorecardsClient.java b/src/main/java/com/merge/api/resources/ats/scorecards/AsyncScorecardsClient.java new file mode 100644 index 000000000..ae16a07e4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/scorecards/AsyncScorecardsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.scorecards; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.scorecards.requests.ScorecardsListRequest; +import com.merge.api.resources.ats.scorecards.requests.ScorecardsRetrieveRequest; +import com.merge.api.resources.ats.types.PaginatedScorecardList; +import com.merge.api.resources.ats.types.Scorecard; +import java.util.concurrent.CompletableFuture; + +public class AsyncScorecardsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawScorecardsClient rawClient; + + public AsyncScorecardsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawScorecardsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawScorecardsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Scorecard objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Scorecard objects. + */ + public CompletableFuture list(ScorecardsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Scorecard objects. + */ + public CompletableFuture list( + ScorecardsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Scorecard object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Scorecard object with the given id. + */ + public CompletableFuture retrieve(String id, ScorecardsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Scorecard object with the given id. + */ + public CompletableFuture retrieve( + String id, ScorecardsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/scorecards/RawScorecardsClient.java b/src/main/java/com/merge/api/resources/ats/scorecards/RawScorecardsClient.java new file mode 100644 index 000000000..ebb2ca3f6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/scorecards/RawScorecardsClient.java @@ -0,0 +1,235 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.scorecards; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.scorecards.requests.ScorecardsListRequest; +import com.merge.api.resources.ats.scorecards.requests.ScorecardsRetrieveRequest; +import com.merge.api.resources.ats.types.PaginatedScorecardList; +import com.merge.api.resources.ats.types.Scorecard; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawScorecardsClient { + protected final ClientOptions clientOptions; + + public RawScorecardsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Scorecard objects. + */ + public MergeApiHttpResponse list() { + return list(ScorecardsListRequest.builder().build()); + } + + /** + * Returns a list of Scorecard objects. + */ + public MergeApiHttpResponse list(ScorecardsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Scorecard objects. + */ + public MergeApiHttpResponse list( + ScorecardsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/scorecards"); + if (request.getApplicationId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "application_id", request.getApplicationId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getInterviewId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "interview_id", request.getInterviewId().get(), false); + } + if (request.getInterviewerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "interviewer_id", request.getInterviewerId().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedScorecardList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Scorecard object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, ScorecardsRetrieveRequest.builder().build()); + } + + /** + * Returns a Scorecard object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, ScorecardsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Scorecard object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, ScorecardsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/scorecards") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Scorecard.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/scorecards/ScorecardsClient.java b/src/main/java/com/merge/api/resources/ats/scorecards/ScorecardsClient.java index c89219fff..17540ede3 100644 --- a/src/main/java/com/merge/api/resources/ats/scorecards/ScorecardsClient.java +++ b/src/main/java/com/merge/api/resources/ats/scorecards/ScorecardsClient.java @@ -3,195 +3,69 @@ */ package com.merge.api.resources.ats.scorecards; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.scorecards.requests.ScorecardsListRequest; import com.merge.api.resources.ats.scorecards.requests.ScorecardsRetrieveRequest; import com.merge.api.resources.ats.types.PaginatedScorecardList; import com.merge.api.resources.ats.types.Scorecard; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ScorecardsClient { protected final ClientOptions clientOptions; + private final RawScorecardsClient rawClient; + public ScorecardsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawScorecardsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawScorecardsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Scorecard objects. */ public PaginatedScorecardList list() { - return list(ScorecardsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Scorecard objects. */ public PaginatedScorecardList list(ScorecardsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Scorecard objects. */ public PaginatedScorecardList list(ScorecardsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/scorecards"); - if (request.getApplicationId().isPresent()) { - httpUrl.addQueryParameter( - "application_id", request.getApplicationId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getInterviewId().isPresent()) { - httpUrl.addQueryParameter("interview_id", request.getInterviewId().get()); - } - if (request.getInterviewerId().isPresent()) { - httpUrl.addQueryParameter( - "interviewer_id", request.getInterviewerId().get()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedScorecardList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Scorecard object with the given id. */ public Scorecard retrieve(String id) { - return retrieve(id, ScorecardsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Scorecard object with the given id. */ public Scorecard retrieve(String id, ScorecardsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Scorecard object with the given id. */ public Scorecard retrieve(String id, ScorecardsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/scorecards") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Scorecard.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/scorecards/requests/ScorecardsListRequest.java b/src/main/java/com/merge/api/resources/ats/scorecards/requests/ScorecardsListRequest.java index 1fad8955e..65dda6e0b 100644 --- a/src/main/java/com/merge/api/resources/ats/scorecards/requests/ScorecardsListRequest.java +++ b/src/main/java/com/merge/api/resources/ats/scorecards/requests/ScorecardsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.scorecards.types.ScorecardsListRequestExpand; +import com.merge.api.resources.ats.scorecards.types.ScorecardsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ScorecardsListRequest.Builder.class) public final class ScorecardsListRequest { + private final Optional> expand; + private final Optional applicationId; private final Optional createdAfter; @@ -30,8 +34,6 @@ public final class ScorecardsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -57,11 +59,11 @@ public final class ScorecardsListRequest { private final Map additionalProperties; private ScorecardsListRequest( + Optional> expand, Optional applicationId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -74,11 +76,11 @@ private ScorecardsListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.applicationId = applicationId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -93,6 +95,14 @@ private ScorecardsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return scorecards for this application. */ @@ -125,14 +135,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -233,11 +235,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(ScorecardsListRequest other) { - return applicationId.equals(other.applicationId) + return expand.equals(other.expand) + && applicationId.equals(other.applicationId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -254,11 +256,11 @@ private boolean equalTo(ScorecardsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.applicationId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -283,6 +285,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional applicationId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -291,8 +295,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -321,11 +323,11 @@ public static final class Builder { private Builder() {} public Builder from(ScorecardsListRequest other) { + expand(other.getExpand()); applicationId(other.getApplicationId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -340,6 +342,22 @@ public Builder from(ScorecardsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(ScorecardsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "application_id", nulls = Nulls.SKIP) public Builder applicationId(Optional applicationId) { this.applicationId = applicationId; @@ -384,17 +402,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(ScorecardsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -518,11 +525,11 @@ public Builder showEnumOrigins(String showEnumOrigins) { public ScorecardsListRequest build() { return new ScorecardsListRequest( + expand, applicationId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ats/scorecards/requests/ScorecardsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/scorecards/requests/ScorecardsRetrieveRequest.java index d54ffd109..54b7189af 100644 --- a/src/main/java/com/merge/api/resources/ats/scorecards/requests/ScorecardsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/scorecards/requests/ScorecardsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ats.scorecards.types.ScorecardsRetrieveRequestExpand; +import com.merge.api.resources.ats.scorecards.types.ScorecardsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,10 +23,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ScorecardsRetrieveRequest.Builder.class) public final class ScorecardsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -32,13 +36,15 @@ public final class ScorecardsRetrieveRequest { private final Map additionalProperties; private ScorecardsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -48,7 +54,7 @@ private ScorecardsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -60,6 +66,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -90,13 +104,15 @@ public Map getAdditionalProperties() { private boolean equalTo(ScorecardsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -110,10 +126,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -126,22 +144,28 @@ private Builder() {} public Builder from(ScorecardsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(ScorecardsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(ScorecardsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -153,6 +177,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -177,7 +212,7 @@ public Builder showEnumOrigins(String showEnumOrigins) { public ScorecardsRetrieveRequest build() { return new ScorecardsRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsListRequestExpand.java b/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsListRequestExpand.java deleted file mode 100644 index 083a88836..000000000 --- a/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsListRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.scorecards.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ScorecardsListRequestExpand { - APPLICATION("application"), - - APPLICATION_INTERVIEW("application,interview"), - - APPLICATION_INTERVIEW_INTERVIEWER("application,interview,interviewer"), - - APPLICATION_INTERVIEWER("application,interviewer"), - - INTERVIEW("interview"), - - INTERVIEW_INTERVIEWER("interview,interviewer"), - - INTERVIEWER("interviewer"); - - private final String value; - - ScorecardsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsListRequestExpandItem.java new file mode 100644 index 000000000..c0927ee6c --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsListRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.scorecards.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ScorecardsListRequestExpandItem { + APPLICATION("application"), + + INTERVIEW("interview"), + + INTERVIEWER("interviewer"); + + private final String value; + + ScorecardsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsRetrieveRequestExpand.java deleted file mode 100644 index f6bde3064..000000000 --- a/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsRetrieveRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.scorecards.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ScorecardsRetrieveRequestExpand { - APPLICATION("application"), - - APPLICATION_INTERVIEW("application,interview"), - - APPLICATION_INTERVIEW_INTERVIEWER("application,interview,interviewer"), - - APPLICATION_INTERVIEWER("application,interviewer"), - - INTERVIEW("interview"), - - INTERVIEW_INTERVIEWER("interview,interviewer"), - - INTERVIEWER("interviewer"); - - private final String value; - - ScorecardsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..f13e37956 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/scorecards/types/ScorecardsRetrieveRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.scorecards.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ScorecardsRetrieveRequestExpandItem { + APPLICATION("application"), + + INTERVIEW("interview"), + + INTERVIEWER("interviewer"); + + private final String value; + + ScorecardsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/syncstatus/AsyncRawSyncStatusClient.java b/src/main/java/com/merge/api/resources/ats/syncstatus/AsyncRawSyncStatusClient.java new file mode 100644 index 000000000..a1dd5ffa2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/syncstatus/AsyncRawSyncStatusClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.ats.types.PaginatedSyncStatusList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawSyncStatusClient { + protected final ClientOptions clientOptions; + + public AsyncRawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedSyncStatusList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/syncstatus/AsyncSyncStatusClient.java b/src/main/java/com/merge/api/resources/ats/syncstatus/AsyncSyncStatusClient.java new file mode 100644 index 000000000..48c95bc5f --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/syncstatus/AsyncSyncStatusClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.syncstatus; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.ats.types.PaginatedSyncStatusList; +import java.util.concurrent.CompletableFuture; + +public class AsyncSyncStatusClient { + protected final ClientOptions clientOptions; + + private final AsyncRawSyncStatusClient rawClient; + + public AsyncSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawSyncStatusClient withRawResponse() { + return this.rawClient; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list(SyncStatusListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list( + SyncStatusListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/syncstatus/RawSyncStatusClient.java b/src/main/java/com/merge/api/resources/ats/syncstatus/RawSyncStatusClient.java new file mode 100644 index 000000000..a082780f5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/syncstatus/RawSyncStatusClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.ats.types.PaginatedSyncStatusList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawSyncStatusClient { + protected final ClientOptions clientOptions; + + public RawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/syncstatus/SyncStatusClient.java b/src/main/java/com/merge/api/resources/ats/syncstatus/SyncStatusClient.java index b9533d672..fadebfb76 100644 --- a/src/main/java/com/merge/api/resources/ats/syncstatus/SyncStatusClient.java +++ b/src/main/java/com/merge/api/resources/ats/syncstatus/SyncStatusClient.java @@ -3,78 +3,46 @@ */ package com.merge.api.resources.ats.syncstatus; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.syncstatus.requests.SyncStatusListRequest; import com.merge.api.resources.ats.types.PaginatedSyncStatusList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class SyncStatusClient { protected final ClientOptions clientOptions; + private final RawSyncStatusClient rawClient; + public SyncStatusClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawSyncStatusClient withRawResponse() { + return this.rawClient; } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list() { - return list(SyncStatusListRequest.builder().build()); + return this.rawClient.list().body(); } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/sync-status"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/tags/AsyncRawTagsClient.java b/src/main/java/com/merge/api/resources/ats/tags/AsyncRawTagsClient.java new file mode 100644 index 000000000..cad21ff75 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/tags/AsyncRawTagsClient.java @@ -0,0 +1,149 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.tags; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.tags.requests.TagsListRequest; +import com.merge.api.resources.ats.types.PaginatedTagList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTagsClient { + protected final ClientOptions clientOptions; + + public AsyncRawTagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture> list() { + return list(TagsListRequest.builder().build()); + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture> list(TagsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture> list( + TagsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/tags"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTagList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/tags/AsyncTagsClient.java b/src/main/java/com/merge/api/resources/ats/tags/AsyncTagsClient.java new file mode 100644 index 000000000..959f42865 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/tags/AsyncTagsClient.java @@ -0,0 +1,49 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.tags; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.tags.requests.TagsListRequest; +import com.merge.api.resources.ats.types.PaginatedTagList; +import java.util.concurrent.CompletableFuture; + +public class AsyncTagsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTagsClient rawClient; + + public AsyncTagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTagsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTagsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture list(TagsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture list(TagsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/tags/RawTagsClient.java b/src/main/java/com/merge/api/resources/ats/tags/RawTagsClient.java new file mode 100644 index 000000000..1ea7720d4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/tags/RawTagsClient.java @@ -0,0 +1,130 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.tags; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.tags.requests.TagsListRequest; +import com.merge.api.resources.ats.types.PaginatedTagList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTagsClient { + protected final ClientOptions clientOptions; + + public RawTagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Tag objects. + */ + public MergeApiHttpResponse list() { + return list(TagsListRequest.builder().build()); + } + + /** + * Returns a list of Tag objects. + */ + public MergeApiHttpResponse list(TagsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Tag objects. + */ + public MergeApiHttpResponse list(TagsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/tags"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTagList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/tags/TagsClient.java b/src/main/java/com/merge/api/resources/ats/tags/TagsClient.java index 16d4567d0..5d50f7396 100644 --- a/src/main/java/com/merge/api/resources/ats/tags/TagsClient.java +++ b/src/main/java/com/merge/api/resources/ats/tags/TagsClient.java @@ -3,110 +3,46 @@ */ package com.merge.api.resources.ats.tags; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.tags.requests.TagsListRequest; import com.merge.api.resources.ats.types.PaginatedTagList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TagsClient { protected final ClientOptions clientOptions; + private final RawTagsClient rawClient; + public TagsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTagsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTagsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Tag objects. */ public PaginatedTagList list() { - return list(TagsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Tag objects. */ public PaginatedTagList list(TagsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Tag objects. */ public PaginatedTagList list(TagsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/tags"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTagList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/types/AccountToken.java b/src/main/java/com/merge/api/resources/ats/types/AccountToken.java index 6acc06eee..7f3a352f3 100644 --- a/src/main/java/com/merge/api/resources/ats/types/AccountToken.java +++ b/src/main/java/com/merge/api/resources/ats/types/AccountToken.java @@ -23,12 +23,15 @@ public final class AccountToken { private final AccountIntegration integration; + private final String id; + private final Map additionalProperties; private AccountToken( - String accountToken, AccountIntegration integration, Map additionalProperties) { + String accountToken, AccountIntegration integration, String id, Map additionalProperties) { this.accountToken = accountToken; this.integration = integration; + this.id = id; this.additionalProperties = additionalProperties; } @@ -42,6 +45,11 @@ public AccountIntegration getIntegration() { return integration; } + @JsonProperty("id") + public String getId() { + return id; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -54,12 +62,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(AccountToken other) { - return accountToken.equals(other.accountToken) && integration.equals(other.integration); + return accountToken.equals(other.accountToken) && integration.equals(other.integration) && id.equals(other.id); } @java.lang.Override public int hashCode() { - return Objects.hash(this.accountToken, this.integration); + return Objects.hash(this.accountToken, this.integration, this.id); } @java.lang.Override @@ -78,7 +86,11 @@ public interface AccountTokenStage { } public interface IntegrationStage { - _FinalStage integration(@NotNull AccountIntegration integration); + IdStage integration(@NotNull AccountIntegration integration); + } + + public interface IdStage { + _FinalStage id(@NotNull String id); } public interface _FinalStage { @@ -86,11 +98,13 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AccountTokenStage, IntegrationStage, _FinalStage { + public static final class Builder implements AccountTokenStage, IntegrationStage, IdStage, _FinalStage { private String accountToken; private AccountIntegration integration; + private String id; + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -100,6 +114,7 @@ private Builder() {} public Builder from(AccountToken other) { accountToken(other.getAccountToken()); integration(other.getIntegration()); + id(other.getId()); return this; } @@ -112,14 +127,21 @@ public IntegrationStage accountToken(@NotNull String accountToken) { @java.lang.Override @JsonSetter("integration") - public _FinalStage integration(@NotNull AccountIntegration integration) { + public IdStage integration(@NotNull AccountIntegration integration) { this.integration = integration; return this; } + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = id; + return this; + } + @java.lang.Override public AccountToken build() { - return new AccountToken(accountToken, integration, additionalProperties); + return new AccountToken(accountToken, integration, id, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/types/Activity.java b/src/main/java/com/merge/api/resources/ats/types/Activity.java index 26a61cda5..e99ea6ee6 100644 --- a/src/main/java/com/merge/api/resources/ats/types/Activity.java +++ b/src/main/java/com/merge/api/resources/ats/types/Activity.java @@ -35,13 +35,13 @@ public final class Activity { private final Optional remoteCreatedAt; - private final Optional activityType; + private final Optional activityType; private final Optional subject; private final Optional body; - private final Optional visibility; + private final Optional visibility; private final Optional candidate; @@ -60,10 +60,10 @@ private Activity( Optional modifiedAt, Optional user, Optional remoteCreatedAt, - Optional activityType, + Optional activityType, Optional subject, Optional body, - Optional visibility, + Optional visibility, Optional candidate, Optional remoteWasDeleted, Optional> fieldMappings, @@ -140,7 +140,7 @@ public Optional getRemoteCreatedAt() { * */ @JsonProperty("activity_type") - public Optional getActivityType() { + public Optional getActivityType() { return activityType; } @@ -169,7 +169,7 @@ public Optional getBody() { * */ @JsonProperty("visibility") - public Optional getVisibility() { + public Optional getVisibility() { return visibility; } @@ -266,13 +266,13 @@ public static final class Builder { private Optional remoteCreatedAt = Optional.empty(); - private Optional activityType = Optional.empty(); + private Optional activityType = Optional.empty(); private Optional subject = Optional.empty(); private Optional body = Optional.empty(); - private Optional visibility = Optional.empty(); + private Optional visibility = Optional.empty(); private Optional candidate = Optional.empty(); @@ -372,12 +372,12 @@ public Builder remoteCreatedAt(OffsetDateTime remoteCreatedAt) { } @JsonSetter(value = "activity_type", nulls = Nulls.SKIP) - public Builder activityType(Optional activityType) { + public Builder activityType(Optional activityType) { this.activityType = activityType; return this; } - public Builder activityType(ActivityActivityType activityType) { + public Builder activityType(ActivityTypeEnum activityType) { this.activityType = Optional.ofNullable(activityType); return this; } @@ -405,12 +405,12 @@ public Builder body(String body) { } @JsonSetter(value = "visibility", nulls = Nulls.SKIP) - public Builder visibility(Optional visibility) { + public Builder visibility(Optional visibility) { this.visibility = visibility; return this; } - public Builder visibility(ActivityVisibility visibility) { + public Builder visibility(VisibilityEnum visibility) { this.visibility = Optional.ofNullable(visibility); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/ActivityActivityType.java b/src/main/java/com/merge/api/resources/ats/types/ActivityActivityType.java deleted file mode 100644 index 0a627c478..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/ActivityActivityType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ActivityActivityType.Deserializer.class) -public final class ActivityActivityType { - private final Object value; - - private final int type; - - private ActivityActivityType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ActivityTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ActivityActivityType && equalTo((ActivityActivityType) other); - } - - private boolean equalTo(ActivityActivityType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ActivityActivityType of(ActivityTypeEnum value) { - return new ActivityActivityType(value, 0); - } - - public static ActivityActivityType of(String value) { - return new ActivityActivityType(value, 1); - } - - public interface Visitor { - T visit(ActivityTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ActivityActivityType.class); - } - - @java.lang.Override - public ActivityActivityType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ActivityTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/ActivityRequest.java b/src/main/java/com/merge/api/resources/ats/types/ActivityRequest.java index 226a85e22..fb48b6298 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ActivityRequest.java +++ b/src/main/java/com/merge/api/resources/ats/types/ActivityRequest.java @@ -23,13 +23,13 @@ public final class ActivityRequest { private final Optional user; - private final Optional activityType; + private final Optional activityType; private final Optional subject; private final Optional body; - private final Optional visibility; + private final Optional visibility; private final Optional candidate; @@ -41,10 +41,10 @@ public final class ActivityRequest { private ActivityRequest( Optional user, - Optional activityType, + Optional activityType, Optional subject, Optional body, - Optional visibility, + Optional visibility, Optional candidate, Optional> integrationParams, Optional> linkedAccountParams, @@ -77,7 +77,7 @@ public Optional getUser() { * */ @JsonProperty("activity_type") - public Optional getActivityType() { + public Optional getActivityType() { return activityType; } @@ -106,7 +106,7 @@ public Optional getBody() { * */ @JsonProperty("visibility") - public Optional getVisibility() { + public Optional getVisibility() { return visibility; } @@ -173,13 +173,13 @@ public static Builder builder() { public static final class Builder { private Optional user = Optional.empty(); - private Optional activityType = Optional.empty(); + private Optional activityType = Optional.empty(); private Optional subject = Optional.empty(); private Optional body = Optional.empty(); - private Optional visibility = Optional.empty(); + private Optional visibility = Optional.empty(); private Optional candidate = Optional.empty(); @@ -216,12 +216,12 @@ public Builder user(ActivityRequestUser user) { } @JsonSetter(value = "activity_type", nulls = Nulls.SKIP) - public Builder activityType(Optional activityType) { + public Builder activityType(Optional activityType) { this.activityType = activityType; return this; } - public Builder activityType(ActivityRequestActivityType activityType) { + public Builder activityType(ActivityTypeEnum activityType) { this.activityType = Optional.ofNullable(activityType); return this; } @@ -249,12 +249,12 @@ public Builder body(String body) { } @JsonSetter(value = "visibility", nulls = Nulls.SKIP) - public Builder visibility(Optional visibility) { + public Builder visibility(Optional visibility) { this.visibility = visibility; return this; } - public Builder visibility(ActivityRequestVisibility visibility) { + public Builder visibility(VisibilityEnum visibility) { this.visibility = Optional.ofNullable(visibility); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/ActivityRequestActivityType.java b/src/main/java/com/merge/api/resources/ats/types/ActivityRequestActivityType.java deleted file mode 100644 index b83affbb3..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/ActivityRequestActivityType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ActivityRequestActivityType.Deserializer.class) -public final class ActivityRequestActivityType { - private final Object value; - - private final int type; - - private ActivityRequestActivityType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ActivityTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ActivityRequestActivityType && equalTo((ActivityRequestActivityType) other); - } - - private boolean equalTo(ActivityRequestActivityType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ActivityRequestActivityType of(ActivityTypeEnum value) { - return new ActivityRequestActivityType(value, 0); - } - - public static ActivityRequestActivityType of(String value) { - return new ActivityRequestActivityType(value, 1); - } - - public interface Visitor { - T visit(ActivityTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ActivityRequestActivityType.class); - } - - @java.lang.Override - public ActivityRequestActivityType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ActivityTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/ActivityRequestUser.java b/src/main/java/com/merge/api/resources/ats/types/ActivityRequestUser.java index ae6c5620b..ebac0939a 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ActivityRequestUser.java +++ b/src/main/java/com/merge/api/resources/ats/types/ActivityRequestUser.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ActivityRequestUser deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ActivityRequestUser deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ActivityRequestVisibility.java b/src/main/java/com/merge/api/resources/ats/types/ActivityRequestVisibility.java deleted file mode 100644 index 798f66bb8..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/ActivityRequestVisibility.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ActivityRequestVisibility.Deserializer.class) -public final class ActivityRequestVisibility { - private final Object value; - - private final int type; - - private ActivityRequestVisibility(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((VisibilityEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ActivityRequestVisibility && equalTo((ActivityRequestVisibility) other); - } - - private boolean equalTo(ActivityRequestVisibility other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ActivityRequestVisibility of(VisibilityEnum value) { - return new ActivityRequestVisibility(value, 0); - } - - public static ActivityRequestVisibility of(String value) { - return new ActivityRequestVisibility(value, 1); - } - - public interface Visitor { - T visit(VisibilityEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ActivityRequestVisibility.class); - } - - @java.lang.Override - public ActivityRequestVisibility deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, VisibilityEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/ActivityUser.java b/src/main/java/com/merge/api/resources/ats/types/ActivityUser.java index 17d65a734..156226bae 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ActivityUser.java +++ b/src/main/java/com/merge/api/resources/ats/types/ActivityUser.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ActivityUser deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ActivityUser deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ActivityVisibility.java b/src/main/java/com/merge/api/resources/ats/types/ActivityVisibility.java deleted file mode 100644 index a96043903..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/ActivityVisibility.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ActivityVisibility.Deserializer.class) -public final class ActivityVisibility { - private final Object value; - - private final int type; - - private ActivityVisibility(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((VisibilityEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ActivityVisibility && equalTo((ActivityVisibility) other); - } - - private boolean equalTo(ActivityVisibility other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ActivityVisibility of(VisibilityEnum value) { - return new ActivityVisibility(value, 0); - } - - public static ActivityVisibility of(String value) { - return new ActivityVisibility(value, 1); - } - - public interface Visitor { - T visit(VisibilityEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ActivityVisibility.class); - } - - @java.lang.Override - public ActivityVisibility deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, VisibilityEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/ApplicationCandidate.java b/src/main/java/com/merge/api/resources/ats/types/ApplicationCandidate.java index 38a3991a8..dc1ea6819 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ApplicationCandidate.java +++ b/src/main/java/com/merge/api/resources/ats/types/ApplicationCandidate.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ApplicationCandidate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ApplicationCandidate deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ApplicationCreditedTo.java b/src/main/java/com/merge/api/resources/ats/types/ApplicationCreditedTo.java index 0124aa5b3..e5360d25c 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ApplicationCreditedTo.java +++ b/src/main/java/com/merge/api/resources/ats/types/ApplicationCreditedTo.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ApplicationCreditedTo deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ApplicationCreditedTo deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ApplicationCurrentStage.java b/src/main/java/com/merge/api/resources/ats/types/ApplicationCurrentStage.java index ab586d70a..89d624795 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ApplicationCurrentStage.java +++ b/src/main/java/com/merge/api/resources/ats/types/ApplicationCurrentStage.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public ApplicationCurrentStage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ApplicationCurrentStage deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ApplicationJob.java b/src/main/java/com/merge/api/resources/ats/types/ApplicationJob.java index 8f224cd4d..808f54dd0 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ApplicationJob.java +++ b/src/main/java/com/merge/api/resources/ats/types/ApplicationJob.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ApplicationJob deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ApplicationJob deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ApplicationOffersItem.java b/src/main/java/com/merge/api/resources/ats/types/ApplicationOffersItem.java index 9d90f742a..ca6c454c1 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ApplicationOffersItem.java +++ b/src/main/java/com/merge/api/resources/ats/types/ApplicationOffersItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ApplicationOffersItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ApplicationOffersItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ApplicationRejectReason.java b/src/main/java/com/merge/api/resources/ats/types/ApplicationRejectReason.java index b8190ecd2..fbacdd4e1 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ApplicationRejectReason.java +++ b/src/main/java/com/merge/api/resources/ats/types/ApplicationRejectReason.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public ApplicationRejectReason deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ApplicationRejectReason deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ApplicationRequestCandidate.java b/src/main/java/com/merge/api/resources/ats/types/ApplicationRequestCandidate.java index ccdf4ffbf..d38d2d17d 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ApplicationRequestCandidate.java +++ b/src/main/java/com/merge/api/resources/ats/types/ApplicationRequestCandidate.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ApplicationRequestJob deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ApplicationRequestJob deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ApplicationRequestOffersItem.java b/src/main/java/com/merge/api/resources/ats/types/ApplicationRequestOffersItem.java index ba4e832bb..d781baf17 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ApplicationRequestOffersItem.java +++ b/src/main/java/com/merge/api/resources/ats/types/ApplicationRequestOffersItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer candidate; - private final Optional attachmentType; + private final Optional attachmentType; private final Optional remoteWasDeleted; @@ -55,7 +55,7 @@ private Attachment( Optional fileName, Optional fileUrl, Optional candidate, - Optional attachmentType, + Optional attachmentType, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -137,7 +137,7 @@ public Optional getCandidate() { * */ @JsonProperty("attachment_type") - public Optional getAttachmentType() { + public Optional getAttachmentType() { return attachmentType; } @@ -225,7 +225,7 @@ public static final class Builder { private Optional candidate = Optional.empty(); - private Optional attachmentType = Optional.empty(); + private Optional attachmentType = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -331,12 +331,12 @@ public Builder candidate(String candidate) { } @JsonSetter(value = "attachment_type", nulls = Nulls.SKIP) - public Builder attachmentType(Optional attachmentType) { + public Builder attachmentType(Optional attachmentType) { this.attachmentType = attachmentType; return this; } - public Builder attachmentType(AttachmentAttachmentType attachmentType) { + public Builder attachmentType(AttachmentTypeEnum attachmentType) { this.attachmentType = Optional.ofNullable(attachmentType); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/AttachmentAttachmentType.java b/src/main/java/com/merge/api/resources/ats/types/AttachmentAttachmentType.java deleted file mode 100644 index 11678b1ea..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/AttachmentAttachmentType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AttachmentAttachmentType.Deserializer.class) -public final class AttachmentAttachmentType { - private final Object value; - - private final int type; - - private AttachmentAttachmentType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AttachmentTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AttachmentAttachmentType && equalTo((AttachmentAttachmentType) other); - } - - private boolean equalTo(AttachmentAttachmentType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AttachmentAttachmentType of(AttachmentTypeEnum value) { - return new AttachmentAttachmentType(value, 0); - } - - public static AttachmentAttachmentType of(String value) { - return new AttachmentAttachmentType(value, 1); - } - - public interface Visitor { - T visit(AttachmentTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AttachmentAttachmentType.class); - } - - @java.lang.Override - public AttachmentAttachmentType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AttachmentTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/AttachmentRequest.java b/src/main/java/com/merge/api/resources/ats/types/AttachmentRequest.java index 028785ad7..04c2f1f09 100644 --- a/src/main/java/com/merge/api/resources/ats/types/AttachmentRequest.java +++ b/src/main/java/com/merge/api/resources/ats/types/AttachmentRequest.java @@ -27,7 +27,7 @@ public final class AttachmentRequest { private final Optional candidate; - private final Optional attachmentType; + private final Optional attachmentType; private final Optional> integrationParams; @@ -39,7 +39,7 @@ private AttachmentRequest( Optional fileName, Optional fileUrl, Optional candidate, - Optional attachmentType, + Optional attachmentType, Optional> integrationParams, Optional> linkedAccountParams, Map additionalProperties) { @@ -86,7 +86,7 @@ public Optional getCandidate() { * */ @JsonProperty("attachment_type") - public Optional getAttachmentType() { + public Optional getAttachmentType() { return attachmentType; } @@ -148,7 +148,7 @@ public static final class Builder { private Optional candidate = Optional.empty(); - private Optional attachmentType = Optional.empty(); + private Optional attachmentType = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -203,12 +203,12 @@ public Builder candidate(String candidate) { } @JsonSetter(value = "attachment_type", nulls = Nulls.SKIP) - public Builder attachmentType(Optional attachmentType) { + public Builder attachmentType(Optional attachmentType) { this.attachmentType = attachmentType; return this; } - public Builder attachmentType(AttachmentRequestAttachmentType attachmentType) { + public Builder attachmentType(AttachmentTypeEnum attachmentType) { this.attachmentType = Optional.ofNullable(attachmentType); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/AttachmentRequestAttachmentType.java b/src/main/java/com/merge/api/resources/ats/types/AttachmentRequestAttachmentType.java deleted file mode 100644 index ea216f02f..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/AttachmentRequestAttachmentType.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AttachmentRequestAttachmentType.Deserializer.class) -public final class AttachmentRequestAttachmentType { - private final Object value; - - private final int type; - - private AttachmentRequestAttachmentType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AttachmentTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AttachmentRequestAttachmentType && equalTo((AttachmentRequestAttachmentType) other); - } - - private boolean equalTo(AttachmentRequestAttachmentType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AttachmentRequestAttachmentType of(AttachmentTypeEnum value) { - return new AttachmentRequestAttachmentType(value, 0); - } - - public static AttachmentRequestAttachmentType of(String value) { - return new AttachmentRequestAttachmentType(value, 1); - } - - public interface Visitor { - T visit(AttachmentTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AttachmentRequestAttachmentType.class); - } - - @java.lang.Override - public AttachmentRequestAttachmentType deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AttachmentTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/AuditLogEvent.java b/src/main/java/com/merge/api/resources/ats/types/AuditLogEvent.java index 105c5fb50..bc64fac33 100644 --- a/src/main/java/com/merge/api/resources/ats/types/AuditLogEvent.java +++ b/src/main/java/com/merge/api/resources/ats/types/AuditLogEvent.java @@ -28,11 +28,11 @@ public final class AuditLogEvent { private final Optional userEmail; - private final AuditLogEventRole role; + private final RoleEnum role; private final String ipAddress; - private final AuditLogEventEventType eventType; + private final EventTypeEnum eventType; private final String eventDescription; @@ -44,9 +44,9 @@ private AuditLogEvent( Optional id, Optional userName, Optional userEmail, - AuditLogEventRole role, + RoleEnum role, String ipAddress, - AuditLogEventEventType eventType, + EventTypeEnum eventType, String eventDescription, Optional createdAt, Map additionalProperties) { @@ -94,7 +94,7 @@ public Optional getUserEmail() { * */ @JsonProperty("role") - public AuditLogEventRole getRole() { + public RoleEnum getRole() { return role; } @@ -115,6 +115,7 @@ public String getIpAddress() { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -150,7 +151,7 @@ public String getIpAddress() { * */ @JsonProperty("event_type") - public AuditLogEventEventType getEventType() { + public EventTypeEnum getEventType() { return eventType; } @@ -209,7 +210,7 @@ public static RoleStage builder() { } public interface RoleStage { - IpAddressStage role(@NotNull AuditLogEventRole role); + IpAddressStage role(@NotNull RoleEnum role); Builder from(AuditLogEvent other); } @@ -219,7 +220,7 @@ public interface IpAddressStage { } public interface EventTypeStage { - EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType); + EventDescriptionStage eventType(@NotNull EventTypeEnum eventType); } public interface EventDescriptionStage { @@ -249,11 +250,11 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements RoleStage, IpAddressStage, EventTypeStage, EventDescriptionStage, _FinalStage { - private AuditLogEventRole role; + private RoleEnum role; private String ipAddress; - private AuditLogEventEventType eventType; + private EventTypeEnum eventType; private String eventDescription; @@ -297,7 +298,7 @@ public Builder from(AuditLogEvent other) { */ @java.lang.Override @JsonSetter("role") - public IpAddressStage role(@NotNull AuditLogEventRole role) { + public IpAddressStage role(@NotNull RoleEnum role) { this.role = role; return this; } @@ -321,6 +322,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -358,7 +360,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { */ @java.lang.Override @JsonSetter("event_type") - public EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType) { + public EventDescriptionStage eventType(@NotNull EventTypeEnum eventType) { this.eventType = eventType; return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/AuditLogEventEventType.java b/src/main/java/com/merge/api/resources/ats/types/AuditLogEventEventType.java deleted file mode 100644 index c9de1a5ea..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/AuditLogEventEventType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventEventType.Deserializer.class) -public final class AuditLogEventEventType { - private final Object value; - - private final int type; - - private AuditLogEventEventType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EventTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventEventType && equalTo((AuditLogEventEventType) other); - } - - private boolean equalTo(AuditLogEventEventType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventEventType of(EventTypeEnum value) { - return new AuditLogEventEventType(value, 0); - } - - public static AuditLogEventEventType of(String value) { - return new AuditLogEventEventType(value, 1); - } - - public interface Visitor { - T visit(EventTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventEventType.class); - } - - @java.lang.Override - public AuditLogEventEventType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EventTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/AuditLogEventRole.java b/src/main/java/com/merge/api/resources/ats/types/AuditLogEventRole.java deleted file mode 100644 index 56eef04ae..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/AuditLogEventRole.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventRole.Deserializer.class) -public final class AuditLogEventRole { - private final Object value; - - private final int type; - - private AuditLogEventRole(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RoleEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventRole && equalTo((AuditLogEventRole) other); - } - - private boolean equalTo(AuditLogEventRole other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventRole of(RoleEnum value) { - return new AuditLogEventRole(value, 0); - } - - public static AuditLogEventRole of(String value) { - return new AuditLogEventRole(value, 1); - } - - public interface Visitor { - T visit(RoleEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventRole.class); - } - - @java.lang.Override - public AuditLogEventRole deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RoleEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/CandidateApplicationsItem.java b/src/main/java/com/merge/api/resources/ats/types/CandidateApplicationsItem.java index 23fc86b86..0154c91e1 100644 --- a/src/main/java/com/merge/api/resources/ats/types/CandidateApplicationsItem.java +++ b/src/main/java/com/merge/api/resources/ats/types/CandidateApplicationsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer submittedAt; - private final Optional race; + private final Optional race; - private final Optional gender; + private final Optional gender; - private final Optional veteranStatus; + private final Optional veteranStatus; - private final Optional disabilityStatus; + private final Optional disabilityStatus; private final Optional remoteWasDeleted; @@ -58,10 +58,10 @@ private Eeoc( Optional modifiedAt, Optional candidate, Optional submittedAt, - Optional race, - Optional gender, - Optional veteranStatus, - Optional disabilityStatus, + Optional race, + Optional gender, + Optional veteranStatus, + Optional disabilityStatus, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -141,7 +141,7 @@ public Optional getSubmittedAt() { * */ @JsonProperty("race") - public Optional getRace() { + public Optional getRace() { return race; } @@ -156,7 +156,7 @@ public Optional getRace() { * */ @JsonProperty("gender") - public Optional getGender() { + public Optional getGender() { return gender; } @@ -169,7 +169,7 @@ public Optional getGender() { * */ @JsonProperty("veteran_status") - public Optional getVeteranStatus() { + public Optional getVeteranStatus() { return veteranStatus; } @@ -182,7 +182,7 @@ public Optional getVeteranStatus() { * */ @JsonProperty("disability_status") - public Optional getDisabilityStatus() { + public Optional getDisabilityStatus() { return disabilityStatus; } @@ -272,13 +272,13 @@ public static final class Builder { private Optional submittedAt = Optional.empty(); - private Optional race = Optional.empty(); + private Optional race = Optional.empty(); - private Optional gender = Optional.empty(); + private Optional gender = Optional.empty(); - private Optional veteranStatus = Optional.empty(); + private Optional veteranStatus = Optional.empty(); - private Optional disabilityStatus = Optional.empty(); + private Optional disabilityStatus = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -375,45 +375,45 @@ public Builder submittedAt(OffsetDateTime submittedAt) { } @JsonSetter(value = "race", nulls = Nulls.SKIP) - public Builder race(Optional race) { + public Builder race(Optional race) { this.race = race; return this; } - public Builder race(EeocRace race) { + public Builder race(RaceEnum race) { this.race = Optional.ofNullable(race); return this; } @JsonSetter(value = "gender", nulls = Nulls.SKIP) - public Builder gender(Optional gender) { + public Builder gender(Optional gender) { this.gender = gender; return this; } - public Builder gender(EeocGender gender) { + public Builder gender(GenderEnum gender) { this.gender = Optional.ofNullable(gender); return this; } @JsonSetter(value = "veteran_status", nulls = Nulls.SKIP) - public Builder veteranStatus(Optional veteranStatus) { + public Builder veteranStatus(Optional veteranStatus) { this.veteranStatus = veteranStatus; return this; } - public Builder veteranStatus(EeocVeteranStatus veteranStatus) { + public Builder veteranStatus(VeteranStatusEnum veteranStatus) { this.veteranStatus = Optional.ofNullable(veteranStatus); return this; } @JsonSetter(value = "disability_status", nulls = Nulls.SKIP) - public Builder disabilityStatus(Optional disabilityStatus) { + public Builder disabilityStatus(Optional disabilityStatus) { this.disabilityStatus = disabilityStatus; return this; } - public Builder disabilityStatus(EeocDisabilityStatus disabilityStatus) { + public Builder disabilityStatus(DisabilityStatusEnum disabilityStatus) { this.disabilityStatus = Optional.ofNullable(disabilityStatus); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/EeocCandidate.java b/src/main/java/com/merge/api/resources/ats/types/EeocCandidate.java index 45c830796..0aca4b49b 100644 --- a/src/main/java/com/merge/api/resources/ats/types/EeocCandidate.java +++ b/src/main/java/com/merge/api/resources/ats/types/EeocCandidate.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EeocCandidate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EeocCandidate deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/EeocDisabilityStatus.java b/src/main/java/com/merge/api/resources/ats/types/EeocDisabilityStatus.java deleted file mode 100644 index 8b426206b..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/EeocDisabilityStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EeocDisabilityStatus.Deserializer.class) -public final class EeocDisabilityStatus { - private final Object value; - - private final int type; - - private EeocDisabilityStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((DisabilityStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EeocDisabilityStatus && equalTo((EeocDisabilityStatus) other); - } - - private boolean equalTo(EeocDisabilityStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EeocDisabilityStatus of(DisabilityStatusEnum value) { - return new EeocDisabilityStatus(value, 0); - } - - public static EeocDisabilityStatus of(String value) { - return new EeocDisabilityStatus(value, 1); - } - - public interface Visitor { - T visit(DisabilityStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EeocDisabilityStatus.class); - } - - @java.lang.Override - public EeocDisabilityStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, DisabilityStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/EeocGender.java b/src/main/java/com/merge/api/resources/ats/types/EeocGender.java deleted file mode 100644 index 4dfa73057..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/EeocGender.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EeocGender.Deserializer.class) -public final class EeocGender { - private final Object value; - - private final int type; - - private EeocGender(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((GenderEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EeocGender && equalTo((EeocGender) other); - } - - private boolean equalTo(EeocGender other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EeocGender of(GenderEnum value) { - return new EeocGender(value, 0); - } - - public static EeocGender of(String value) { - return new EeocGender(value, 1); - } - - public interface Visitor { - T visit(GenderEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EeocGender.class); - } - - @java.lang.Override - public EeocGender deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, GenderEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/EeocRace.java b/src/main/java/com/merge/api/resources/ats/types/EeocRace.java deleted file mode 100644 index 1f345517a..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/EeocRace.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EeocRace.Deserializer.class) -public final class EeocRace { - private final Object value; - - private final int type; - - private EeocRace(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RaceEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EeocRace && equalTo((EeocRace) other); - } - - private boolean equalTo(EeocRace other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EeocRace of(RaceEnum value) { - return new EeocRace(value, 0); - } - - public static EeocRace of(String value) { - return new EeocRace(value, 1); - } - - public interface Visitor { - T visit(RaceEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EeocRace.class); - } - - @java.lang.Override - public EeocRace deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RaceEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/EeocVeteranStatus.java b/src/main/java/com/merge/api/resources/ats/types/EeocVeteranStatus.java deleted file mode 100644 index e21d445ab..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/EeocVeteranStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EeocVeteranStatus.Deserializer.class) -public final class EeocVeteranStatus { - private final Object value; - - private final int type; - - private EeocVeteranStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((VeteranStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EeocVeteranStatus && equalTo((EeocVeteranStatus) other); - } - - private boolean equalTo(EeocVeteranStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EeocVeteranStatus of(VeteranStatusEnum value) { - return new EeocVeteranStatus(value, 0); - } - - public static EeocVeteranStatus of(String value) { - return new EeocVeteranStatus(value, 1); - } - - public interface Visitor { - T visit(VeteranStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EeocVeteranStatus.class); - } - - @java.lang.Override - public EeocVeteranStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, VeteranStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/EmailAddress.java b/src/main/java/com/merge/api/resources/ats/types/EmailAddress.java index 3bfc073a8..4a58c3fd3 100644 --- a/src/main/java/com/merge/api/resources/ats/types/EmailAddress.java +++ b/src/main/java/com/merge/api/resources/ats/types/EmailAddress.java @@ -27,7 +27,7 @@ public final class EmailAddress { private final Optional value; - private final Optional emailAddressType; + private final Optional emailAddressType; private final Optional remoteWasDeleted; @@ -37,7 +37,7 @@ private EmailAddress( Optional createdAt, Optional modifiedAt, Optional value, - Optional emailAddressType, + Optional emailAddressType, Optional remoteWasDeleted, Map additionalProperties) { this.createdAt = createdAt; @@ -81,7 +81,7 @@ public Optional getValue() { * */ @JsonProperty("email_address_type") - public Optional getEmailAddressType() { + public Optional getEmailAddressType() { return emailAddressType; } @@ -134,7 +134,7 @@ public static final class Builder { private Optional value = Optional.empty(); - private Optional emailAddressType = Optional.empty(); + private Optional emailAddressType = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -186,12 +186,12 @@ public Builder value(String value) { } @JsonSetter(value = "email_address_type", nulls = Nulls.SKIP) - public Builder emailAddressType(Optional emailAddressType) { + public Builder emailAddressType(Optional emailAddressType) { this.emailAddressType = emailAddressType; return this; } - public Builder emailAddressType(EmailAddressEmailAddressType emailAddressType) { + public Builder emailAddressType(EmailAddressTypeEnum emailAddressType) { this.emailAddressType = Optional.ofNullable(emailAddressType); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/EmailAddressEmailAddressType.java b/src/main/java/com/merge/api/resources/ats/types/EmailAddressEmailAddressType.java deleted file mode 100644 index bfb5aef33..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/EmailAddressEmailAddressType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmailAddressEmailAddressType.Deserializer.class) -public final class EmailAddressEmailAddressType { - private final Object value; - - private final int type; - - private EmailAddressEmailAddressType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EmailAddressTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmailAddressEmailAddressType && equalTo((EmailAddressEmailAddressType) other); - } - - private boolean equalTo(EmailAddressEmailAddressType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmailAddressEmailAddressType of(EmailAddressTypeEnum value) { - return new EmailAddressEmailAddressType(value, 0); - } - - public static EmailAddressEmailAddressType of(String value) { - return new EmailAddressEmailAddressType(value, 1); - } - - public interface Visitor { - T visit(EmailAddressTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmailAddressEmailAddressType.class); - } - - @java.lang.Override - public EmailAddressEmailAddressType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EmailAddressTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/EmailAddressRequest.java b/src/main/java/com/merge/api/resources/ats/types/EmailAddressRequest.java index 546cc387f..8ce9ce0c9 100644 --- a/src/main/java/com/merge/api/resources/ats/types/EmailAddressRequest.java +++ b/src/main/java/com/merge/api/resources/ats/types/EmailAddressRequest.java @@ -23,7 +23,7 @@ public final class EmailAddressRequest { private final Optional value; - private final Optional emailAddressType; + private final Optional emailAddressType; private final Optional> integrationParams; @@ -33,7 +33,7 @@ public final class EmailAddressRequest { private EmailAddressRequest( Optional value, - Optional emailAddressType, + Optional emailAddressType, Optional> integrationParams, Optional> linkedAccountParams, Map additionalProperties) { @@ -61,7 +61,7 @@ public Optional getValue() { * */ @JsonProperty("email_address_type") - public Optional getEmailAddressType() { + public Optional getEmailAddressType() { return emailAddressType; } @@ -111,7 +111,7 @@ public static Builder builder() { public static final class Builder { private Optional value = Optional.empty(); - private Optional emailAddressType = Optional.empty(); + private Optional emailAddressType = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -142,12 +142,12 @@ public Builder value(String value) { } @JsonSetter(value = "email_address_type", nulls = Nulls.SKIP) - public Builder emailAddressType(Optional emailAddressType) { + public Builder emailAddressType(Optional emailAddressType) { this.emailAddressType = emailAddressType; return this; } - public Builder emailAddressType(EmailAddressRequestEmailAddressType emailAddressType) { + public Builder emailAddressType(EmailAddressTypeEnum emailAddressType) { this.emailAddressType = Optional.ofNullable(emailAddressType); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/EmailAddressRequestEmailAddressType.java b/src/main/java/com/merge/api/resources/ats/types/EmailAddressRequestEmailAddressType.java deleted file mode 100644 index b7a94cfa6..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/EmailAddressRequestEmailAddressType.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmailAddressRequestEmailAddressType.Deserializer.class) -public final class EmailAddressRequestEmailAddressType { - private final Object value; - - private final int type; - - private EmailAddressRequestEmailAddressType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EmailAddressTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmailAddressRequestEmailAddressType - && equalTo((EmailAddressRequestEmailAddressType) other); - } - - private boolean equalTo(EmailAddressRequestEmailAddressType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmailAddressRequestEmailAddressType of(EmailAddressTypeEnum value) { - return new EmailAddressRequestEmailAddressType(value, 0); - } - - public static EmailAddressRequestEmailAddressType of(String value) { - return new EmailAddressRequestEmailAddressType(value, 1); - } - - public interface Visitor { - T visit(EmailAddressTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmailAddressRequestEmailAddressType.class); - } - - @java.lang.Override - public EmailAddressRequestEmailAddressType deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EmailAddressTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/EventTypeEnum.java b/src/main/java/com/merge/api/resources/ats/types/EventTypeEnum.java index cbbb99e0a..c07e1e07d 100644 --- a/src/main/java/com/merge/api/resources/ats/types/EventTypeEnum.java +++ b/src/main/java/com/merge/api/resources/ats/types/EventTypeEnum.java @@ -24,6 +24,8 @@ public enum EventTypeEnum { DELETED_LINKED_ACCOUNT("DELETED_LINKED_ACCOUNT"), + DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT("DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT"), + CREATED_DESTINATION("CREATED_DESTINATION"), DELETED_DESTINATION("DELETED_DESTINATION"), diff --git a/src/main/java/com/merge/api/resources/ats/types/IgnoreCommonModelRequest.java b/src/main/java/com/merge/api/resources/ats/types/IgnoreCommonModelRequest.java new file mode 100644 index 000000000..2fb0f9199 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/types/IgnoreCommonModelRequest.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = IgnoreCommonModelRequest.Builder.class) +public final class IgnoreCommonModelRequest { + private final ReasonEnum reason; + + private final Optional message; + + private final Map additionalProperties; + + private IgnoreCommonModelRequest( + ReasonEnum reason, Optional message, Map additionalProperties) { + this.reason = reason; + this.message = message; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("reason") + public ReasonEnum getReason() { + return reason; + } + + @JsonProperty("message") + public Optional getMessage() { + return message; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof IgnoreCommonModelRequest && equalTo((IgnoreCommonModelRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(IgnoreCommonModelRequest other) { + return reason.equals(other.reason) && message.equals(other.message); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.reason, this.message); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ReasonStage builder() { + return new Builder(); + } + + public interface ReasonStage { + _FinalStage reason(@NotNull ReasonEnum reason); + + Builder from(IgnoreCommonModelRequest other); + } + + public interface _FinalStage { + IgnoreCommonModelRequest build(); + + _FinalStage message(Optional message); + + _FinalStage message(String message); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ReasonStage, _FinalStage { + private ReasonEnum reason; + + private Optional message = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(IgnoreCommonModelRequest other) { + reason(other.getReason()); + message(other.getMessage()); + return this; + } + + @java.lang.Override + @JsonSetter("reason") + public _FinalStage reason(@NotNull ReasonEnum reason) { + this.reason = reason; + return this; + } + + @java.lang.Override + public _FinalStage message(String message) { + this.message = Optional.ofNullable(message); + return this; + } + + @java.lang.Override + @JsonSetter(value = "message", nulls = Nulls.SKIP) + public _FinalStage message(Optional message) { + this.message = message; + return this; + } + + @java.lang.Override + public IgnoreCommonModelRequest build() { + return new IgnoreCommonModelRequest(reason, message, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/types/Issue.java b/src/main/java/com/merge/api/resources/ats/types/Issue.java index ad13c7086..075b3bf09 100644 --- a/src/main/java/com/merge/api/resources/ats/types/Issue.java +++ b/src/main/java/com/merge/api/resources/ats/types/Issue.java @@ -26,7 +26,7 @@ public final class Issue { private final Optional id; - private final Optional status; + private final Optional status; private final String errorDescription; @@ -44,7 +44,7 @@ public final class Issue { private Issue( Optional id, - Optional status, + Optional status, String errorDescription, Optional> endUser, Optional firstIncidentTime, @@ -76,7 +76,7 @@ public Optional getId() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -167,9 +167,9 @@ public interface _FinalStage { _FinalStage id(String id); - _FinalStage status(Optional status); + _FinalStage status(Optional status); - _FinalStage status(IssueStatus status); + _FinalStage status(IssueStatusEnum status); _FinalStage endUser(Optional> endUser); @@ -206,7 +206,7 @@ public static final class Builder implements ErrorDescriptionStage, _FinalStage private Optional> endUser = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional id = Optional.empty(); @@ -309,14 +309,14 @@ public _FinalStage endUser(Optional> endUser) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage status(IssueStatus status) { + public _FinalStage status(IssueStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @java.lang.Override @JsonSetter(value = "status", nulls = Nulls.SKIP) - public _FinalStage status(Optional status) { + public _FinalStage status(Optional status) { this.status = status; return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/IssueStatus.java b/src/main/java/com/merge/api/resources/ats/types/IssueStatus.java deleted file mode 100644 index 1b6845c14..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/IssueStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = IssueStatus.Deserializer.class) -public final class IssueStatus { - private final Object value; - - private final int type; - - private IssueStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((IssueStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IssueStatus && equalTo((IssueStatus) other); - } - - private boolean equalTo(IssueStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static IssueStatus of(IssueStatusEnum value) { - return new IssueStatus(value, 0); - } - - public static IssueStatus of(String value) { - return new IssueStatus(value, 1); - } - - public interface Visitor { - T visit(IssueStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(IssueStatus.class); - } - - @java.lang.Override - public IssueStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, IssueStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/Job.java b/src/main/java/com/merge/api/resources/ats/types/Job.java index e41a3f926..e823a711a 100644 --- a/src/main/java/com/merge/api/resources/ats/types/Job.java +++ b/src/main/java/com/merge/api/resources/ats/types/Job.java @@ -37,7 +37,7 @@ public final class Job { private final Optional code; - private final Optional status; + private final Optional status; private final Optional type; @@ -75,7 +75,7 @@ private Job( Optional name, Optional description, Optional code, - Optional status, + Optional status, Optional type, Optional>> jobPostings, Optional> jobPostingUrls, @@ -178,7 +178,7 @@ public Optional getCode() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -368,7 +368,7 @@ public static final class Builder { private Optional code = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional type = Optional.empty(); @@ -504,12 +504,12 @@ public Builder code(String code) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(JobStatus status) { + public Builder status(JobStatusEnum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/JobDepartmentsItem.java b/src/main/java/com/merge/api/resources/ats/types/JobDepartmentsItem.java index 7d1bcc7e5..6916d1264 100644 --- a/src/main/java/com/merge/api/resources/ats/types/JobDepartmentsItem.java +++ b/src/main/java/com/merge/api/resources/ats/types/JobDepartmentsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public JobDepartmentsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public JobDepartmentsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/JobHiringManagersItem.java b/src/main/java/com/merge/api/resources/ats/types/JobHiringManagersItem.java index a462d503e..fc7278cc0 100644 --- a/src/main/java/com/merge/api/resources/ats/types/JobHiringManagersItem.java +++ b/src/main/java/com/merge/api/resources/ats/types/JobHiringManagersItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public JobHiringManagersItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public JobHiringManagersItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/JobInterviewStageJob.java b/src/main/java/com/merge/api/resources/ats/types/JobInterviewStageJob.java index 5859a8e2f..172eda393 100644 --- a/src/main/java/com/merge/api/resources/ats/types/JobInterviewStageJob.java +++ b/src/main/java/com/merge/api/resources/ats/types/JobInterviewStageJob.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public JobInterviewStageJob deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public JobInterviewStageJob deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/JobOfficesItem.java b/src/main/java/com/merge/api/resources/ats/types/JobOfficesItem.java index 69418a273..fc1b05e9a 100644 --- a/src/main/java/com/merge/api/resources/ats/types/JobOfficesItem.java +++ b/src/main/java/com/merge/api/resources/ats/types/JobOfficesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public JobOfficesItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public JobOfficesItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/JobPostingJob.java b/src/main/java/com/merge/api/resources/ats/types/JobPostingJob.java index 8973f0695..90ca63e24 100644 --- a/src/main/java/com/merge/api/resources/ats/types/JobPostingJob.java +++ b/src/main/java/com/merge/api/resources/ats/types/JobPostingJob.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public JobPostingJob deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public JobPostingJob deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/JobPostingJobPostingUrlsItem.java b/src/main/java/com/merge/api/resources/ats/types/JobPostingJobPostingUrlsItem.java index 4472dab38..4a2e38b8e 100644 --- a/src/main/java/com/merge/api/resources/ats/types/JobPostingJobPostingUrlsItem.java +++ b/src/main/java/com/merge/api/resources/ats/types/JobPostingJobPostingUrlsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public JobRecruitersItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public JobRecruitersItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/JobStatus.java b/src/main/java/com/merge/api/resources/ats/types/JobStatus.java deleted file mode 100644 index 18cb646c1..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/JobStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = JobStatus.Deserializer.class) -public final class JobStatus { - private final Object value; - - private final int type; - - private JobStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((JobStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof JobStatus && equalTo((JobStatus) other); - } - - private boolean equalTo(JobStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static JobStatus of(JobStatusEnum value) { - return new JobStatus(value, 0); - } - - public static JobStatus of(String value) { - return new JobStatus(value, 1); - } - - public interface Visitor { - T visit(JobStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(JobStatus.class); - } - - @java.lang.Override - public JobStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, JobStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/LastSyncResultEnum.java b/src/main/java/com/merge/api/resources/ats/types/LastSyncResultEnum.java new file mode 100644 index 000000000..325b21516 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/types/LastSyncResultEnum.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum LastSyncResultEnum { + SYNCING("SYNCING"), + + DONE("DONE"), + + FAILED("FAILED"), + + DISABLED("DISABLED"), + + PAUSED("PAUSED"), + + PARTIALLY_SYNCED("PARTIALLY_SYNCED"); + + private final String value; + + LastSyncResultEnum(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/types/MultipartFormFieldRequest.java b/src/main/java/com/merge/api/resources/ats/types/MultipartFormFieldRequest.java index 94682fda3..1449cdcea 100644 --- a/src/main/java/com/merge/api/resources/ats/types/MultipartFormFieldRequest.java +++ b/src/main/java/com/merge/api/resources/ats/types/MultipartFormFieldRequest.java @@ -25,7 +25,7 @@ public final class MultipartFormFieldRequest { private final String data; - private final Optional encoding; + private final Optional encoding; private final Optional fileName; @@ -36,7 +36,7 @@ public final class MultipartFormFieldRequest { private MultipartFormFieldRequest( String name, String data, - Optional encoding, + Optional encoding, Optional fileName, Optional contentType, Map additionalProperties) { @@ -73,7 +73,7 @@ public String getData() { * */ @JsonProperty("encoding") - public Optional getEncoding() { + public Optional getEncoding() { return encoding; } @@ -139,9 +139,9 @@ public interface DataStage { public interface _FinalStage { MultipartFormFieldRequest build(); - _FinalStage encoding(Optional encoding); + _FinalStage encoding(Optional encoding); - _FinalStage encoding(MultipartFormFieldRequestEncoding encoding); + _FinalStage encoding(EncodingEnum encoding); _FinalStage fileName(Optional fileName); @@ -162,7 +162,7 @@ public static final class Builder implements NameStage, DataStage, _FinalStage { private Optional fileName = Optional.empty(); - private Optional encoding = Optional.empty(); + private Optional encoding = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -245,14 +245,14 @@ public _FinalStage fileName(Optional fileName) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage encoding(MultipartFormFieldRequestEncoding encoding) { + public _FinalStage encoding(EncodingEnum encoding) { this.encoding = Optional.ofNullable(encoding); return this; } @java.lang.Override @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { + public _FinalStage encoding(Optional encoding) { this.encoding = encoding; return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/MultipartFormFieldRequestEncoding.java b/src/main/java/com/merge/api/resources/ats/types/MultipartFormFieldRequestEncoding.java deleted file mode 100644 index f60d846f0..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/MultipartFormFieldRequestEncoding.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = MultipartFormFieldRequestEncoding.Deserializer.class) -public final class MultipartFormFieldRequestEncoding { - private final Object value; - - private final int type; - - private MultipartFormFieldRequestEncoding(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EncodingEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MultipartFormFieldRequestEncoding && equalTo((MultipartFormFieldRequestEncoding) other); - } - - private boolean equalTo(MultipartFormFieldRequestEncoding other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static MultipartFormFieldRequestEncoding of(EncodingEnum value) { - return new MultipartFormFieldRequestEncoding(value, 0); - } - - public static MultipartFormFieldRequestEncoding of(String value) { - return new MultipartFormFieldRequestEncoding(value, 1); - } - - public interface Visitor { - T visit(EncodingEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(MultipartFormFieldRequestEncoding.class); - } - - @java.lang.Override - public MultipartFormFieldRequestEncoding deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EncodingEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/Offer.java b/src/main/java/com/merge/api/resources/ats/types/Offer.java index 3354e8911..491fc7d7f 100644 --- a/src/main/java/com/merge/api/resources/ats/types/Offer.java +++ b/src/main/java/com/merge/api/resources/ats/types/Offer.java @@ -43,7 +43,7 @@ public final class Offer { private final Optional startDate; - private final Optional status; + private final Optional status; private final Optional remoteWasDeleted; @@ -64,7 +64,7 @@ private Offer( Optional closedAt, Optional sentAt, Optional startDate, - Optional status, + Optional status, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -178,7 +178,7 @@ public Optional getStartDate() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -278,7 +278,7 @@ public static final class Builder { private Optional startDate = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -420,12 +420,12 @@ public Builder startDate(OffsetDateTime startDate) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(OfferStatus status) { + public Builder status(OfferStatusEnum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/OfferApplication.java b/src/main/java/com/merge/api/resources/ats/types/OfferApplication.java index ecfec0c61..d6bd3a11b 100644 --- a/src/main/java/com/merge/api/resources/ats/types/OfferApplication.java +++ b/src/main/java/com/merge/api/resources/ats/types/OfferApplication.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public OfferApplication deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public OfferApplication deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/OfferCreator.java b/src/main/java/com/merge/api/resources/ats/types/OfferCreator.java index 1d332b003..501f6eeaf 100644 --- a/src/main/java/com/merge/api/resources/ats/types/OfferCreator.java +++ b/src/main/java/com/merge/api/resources/ats/types/OfferCreator.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public OfferCreator deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public OfferCreator deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/OfferStatus.java b/src/main/java/com/merge/api/resources/ats/types/OfferStatus.java deleted file mode 100644 index e3b03dfcf..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/OfferStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = OfferStatus.Deserializer.class) -public final class OfferStatus { - private final Object value; - - private final int type; - - private OfferStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((OfferStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof OfferStatus && equalTo((OfferStatus) other); - } - - private boolean equalTo(OfferStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static OfferStatus of(OfferStatusEnum value) { - return new OfferStatus(value, 0); - } - - public static OfferStatus of(String value) { - return new OfferStatus(value, 1); - } - - public interface Visitor { - T visit(OfferStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(OfferStatus.class); - } - - @java.lang.Override - public OfferStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, OfferStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/PhoneNumber.java b/src/main/java/com/merge/api/resources/ats/types/PhoneNumber.java index bb739368b..0653c6c1f 100644 --- a/src/main/java/com/merge/api/resources/ats/types/PhoneNumber.java +++ b/src/main/java/com/merge/api/resources/ats/types/PhoneNumber.java @@ -27,7 +27,7 @@ public final class PhoneNumber { private final Optional value; - private final Optional phoneNumberType; + private final Optional phoneNumberType; private final Optional remoteWasDeleted; @@ -37,7 +37,7 @@ private PhoneNumber( Optional createdAt, Optional modifiedAt, Optional value, - Optional phoneNumberType, + Optional phoneNumberType, Optional remoteWasDeleted, Map additionalProperties) { this.createdAt = createdAt; @@ -83,7 +83,7 @@ public Optional getValue() { * */ @JsonProperty("phone_number_type") - public Optional getPhoneNumberType() { + public Optional getPhoneNumberType() { return phoneNumberType; } @@ -136,7 +136,7 @@ public static final class Builder { private Optional value = Optional.empty(); - private Optional phoneNumberType = Optional.empty(); + private Optional phoneNumberType = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -188,12 +188,12 @@ public Builder value(String value) { } @JsonSetter(value = "phone_number_type", nulls = Nulls.SKIP) - public Builder phoneNumberType(Optional phoneNumberType) { + public Builder phoneNumberType(Optional phoneNumberType) { this.phoneNumberType = phoneNumberType; return this; } - public Builder phoneNumberType(PhoneNumberPhoneNumberType phoneNumberType) { + public Builder phoneNumberType(PhoneNumberTypeEnum phoneNumberType) { this.phoneNumberType = Optional.ofNullable(phoneNumberType); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/PhoneNumberPhoneNumberType.java b/src/main/java/com/merge/api/resources/ats/types/PhoneNumberPhoneNumberType.java deleted file mode 100644 index c14d32a40..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/PhoneNumberPhoneNumberType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PhoneNumberPhoneNumberType.Deserializer.class) -public final class PhoneNumberPhoneNumberType { - private final Object value; - - private final int type; - - private PhoneNumberPhoneNumberType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PhoneNumberTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PhoneNumberPhoneNumberType && equalTo((PhoneNumberPhoneNumberType) other); - } - - private boolean equalTo(PhoneNumberPhoneNumberType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PhoneNumberPhoneNumberType of(PhoneNumberTypeEnum value) { - return new PhoneNumberPhoneNumberType(value, 0); - } - - public static PhoneNumberPhoneNumberType of(String value) { - return new PhoneNumberPhoneNumberType(value, 1); - } - - public interface Visitor { - T visit(PhoneNumberTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PhoneNumberPhoneNumberType.class); - } - - @java.lang.Override - public PhoneNumberPhoneNumberType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PhoneNumberTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/PhoneNumberRequest.java b/src/main/java/com/merge/api/resources/ats/types/PhoneNumberRequest.java index d772ce948..c11d84e77 100644 --- a/src/main/java/com/merge/api/resources/ats/types/PhoneNumberRequest.java +++ b/src/main/java/com/merge/api/resources/ats/types/PhoneNumberRequest.java @@ -23,7 +23,7 @@ public final class PhoneNumberRequest { private final Optional value; - private final Optional phoneNumberType; + private final Optional phoneNumberType; private final Optional> integrationParams; @@ -33,7 +33,7 @@ public final class PhoneNumberRequest { private PhoneNumberRequest( Optional value, - Optional phoneNumberType, + Optional phoneNumberType, Optional> integrationParams, Optional> linkedAccountParams, Map additionalProperties) { @@ -63,7 +63,7 @@ public Optional getValue() { * */ @JsonProperty("phone_number_type") - public Optional getPhoneNumberType() { + public Optional getPhoneNumberType() { return phoneNumberType; } @@ -113,7 +113,7 @@ public static Builder builder() { public static final class Builder { private Optional value = Optional.empty(); - private Optional phoneNumberType = Optional.empty(); + private Optional phoneNumberType = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -144,12 +144,12 @@ public Builder value(String value) { } @JsonSetter(value = "phone_number_type", nulls = Nulls.SKIP) - public Builder phoneNumberType(Optional phoneNumberType) { + public Builder phoneNumberType(Optional phoneNumberType) { this.phoneNumberType = phoneNumberType; return this; } - public Builder phoneNumberType(PhoneNumberRequestPhoneNumberType phoneNumberType) { + public Builder phoneNumberType(PhoneNumberTypeEnum phoneNumberType) { this.phoneNumberType = Optional.ofNullable(phoneNumberType); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/PhoneNumberRequestPhoneNumberType.java b/src/main/java/com/merge/api/resources/ats/types/PhoneNumberRequestPhoneNumberType.java deleted file mode 100644 index 0a60a42d6..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/PhoneNumberRequestPhoneNumberType.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PhoneNumberRequestPhoneNumberType.Deserializer.class) -public final class PhoneNumberRequestPhoneNumberType { - private final Object value; - - private final int type; - - private PhoneNumberRequestPhoneNumberType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PhoneNumberTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PhoneNumberRequestPhoneNumberType && equalTo((PhoneNumberRequestPhoneNumberType) other); - } - - private boolean equalTo(PhoneNumberRequestPhoneNumberType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PhoneNumberRequestPhoneNumberType of(PhoneNumberTypeEnum value) { - return new PhoneNumberRequestPhoneNumberType(value, 0); - } - - public static PhoneNumberRequestPhoneNumberType of(String value) { - return new PhoneNumberRequestPhoneNumberType(value, 1); - } - - public interface Visitor { - T visit(PhoneNumberTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PhoneNumberRequestPhoneNumberType.class); - } - - @java.lang.Override - public PhoneNumberRequestPhoneNumberType deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PhoneNumberTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/RemoteFieldApiCoverage.java b/src/main/java/com/merge/api/resources/ats/types/RemoteFieldApiCoverage.java index 902f1c51c..05cf8229d 100644 --- a/src/main/java/com/merge/api/resources/ats/types/RemoteFieldApiCoverage.java +++ b/src/main/java/com/merge/api/resources/ats/types/RemoteFieldApiCoverage.java @@ -28,6 +28,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((int) this.value); @@ -77,7 +78,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); if (value instanceof Integer) { return of((Integer) value); diff --git a/src/main/java/com/merge/api/resources/ats/types/RemoteResponse.java b/src/main/java/com/merge/api/resources/ats/types/RemoteResponse.java index d8b7727d3..1d7406690 100644 --- a/src/main/java/com/merge/api/resources/ats/types/RemoteResponse.java +++ b/src/main/java/com/merge/api/resources/ats/types/RemoteResponse.java @@ -32,7 +32,7 @@ public final class RemoteResponse { private final Optional> responseHeaders; - private final Optional responseType; + private final Optional responseType; private final Optional> headers; @@ -44,7 +44,7 @@ private RemoteResponse( int status, JsonNode response, Optional> responseHeaders, - Optional responseType, + Optional responseType, Optional> headers, Map additionalProperties) { this.method = method; @@ -83,7 +83,7 @@ public Optional> getResponseHeaders() { } @JsonProperty("response_type") - public Optional getResponseType() { + public Optional getResponseType() { return responseType; } @@ -159,9 +159,9 @@ public interface _FinalStage { _FinalStage responseHeaders(Map responseHeaders); - _FinalStage responseType(Optional responseType); + _FinalStage responseType(Optional responseType); - _FinalStage responseType(RemoteResponseResponseType responseType); + _FinalStage responseType(ResponseTypeEnum responseType); _FinalStage headers(Optional> headers); @@ -180,7 +180,7 @@ public static final class Builder implements MethodStage, PathStage, StatusStage private Optional> headers = Optional.empty(); - private Optional responseType = Optional.empty(); + private Optional responseType = Optional.empty(); private Optional> responseHeaders = Optional.empty(); @@ -243,14 +243,14 @@ public _FinalStage headers(Optional> headers) { } @java.lang.Override - public _FinalStage responseType(RemoteResponseResponseType responseType) { + public _FinalStage responseType(ResponseTypeEnum responseType) { this.responseType = Optional.ofNullable(responseType); return this; } @java.lang.Override @JsonSetter(value = "response_type", nulls = Nulls.SKIP) - public _FinalStage responseType(Optional responseType) { + public _FinalStage responseType(Optional responseType) { this.responseType = responseType; return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/RemoteResponseResponseType.java b/src/main/java/com/merge/api/resources/ats/types/RemoteResponseResponseType.java deleted file mode 100644 index a0c5c62b6..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/RemoteResponseResponseType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RemoteResponseResponseType.Deserializer.class) -public final class RemoteResponseResponseType { - private final Object value; - - private final int type; - - private RemoteResponseResponseType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ResponseTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RemoteResponseResponseType && equalTo((RemoteResponseResponseType) other); - } - - private boolean equalTo(RemoteResponseResponseType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RemoteResponseResponseType of(ResponseTypeEnum value) { - return new RemoteResponseResponseType(value, 0); - } - - public static RemoteResponseResponseType of(String value) { - return new RemoteResponseResponseType(value, 1); - } - - public interface Visitor { - T visit(ResponseTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RemoteResponseResponseType.class); - } - - @java.lang.Override - public RemoteResponseResponseType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ResponseTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/RemoteUser.java b/src/main/java/com/merge/api/resources/ats/types/RemoteUser.java index 3d4c66f3c..e54542328 100644 --- a/src/main/java/com/merge/api/resources/ats/types/RemoteUser.java +++ b/src/main/java/com/merge/api/resources/ats/types/RemoteUser.java @@ -41,7 +41,7 @@ public final class RemoteUser { private final Optional remoteCreatedAt; - private final Optional accessRole; + private final Optional accessRole; private final Optional remoteWasDeleted; @@ -61,7 +61,7 @@ private RemoteUser( Optional email, Optional disabled, Optional remoteCreatedAt, - Optional accessRole, + Optional accessRole, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -162,7 +162,7 @@ public Optional getRemoteCreatedAt() { * */ @JsonProperty("access_role") - public Optional getAccessRole() { + public Optional getAccessRole() { return accessRole; } @@ -258,7 +258,7 @@ public static final class Builder { private Optional remoteCreatedAt = Optional.empty(); - private Optional accessRole = Optional.empty(); + private Optional accessRole = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -388,12 +388,12 @@ public Builder remoteCreatedAt(OffsetDateTime remoteCreatedAt) { } @JsonSetter(value = "access_role", nulls = Nulls.SKIP) - public Builder accessRole(Optional accessRole) { + public Builder accessRole(Optional accessRole) { this.accessRole = accessRole; return this; } - public Builder accessRole(RemoteUserAccessRole accessRole) { + public Builder accessRole(AccessRoleEnum accessRole) { this.accessRole = Optional.ofNullable(accessRole); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/RemoteUserAccessRole.java b/src/main/java/com/merge/api/resources/ats/types/RemoteUserAccessRole.java deleted file mode 100644 index 92ecb01c1..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/RemoteUserAccessRole.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RemoteUserAccessRole.Deserializer.class) -public final class RemoteUserAccessRole { - private final Object value; - - private final int type; - - private RemoteUserAccessRole(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AccessRoleEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RemoteUserAccessRole && equalTo((RemoteUserAccessRole) other); - } - - private boolean equalTo(RemoteUserAccessRole other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RemoteUserAccessRole of(AccessRoleEnum value) { - return new RemoteUserAccessRole(value, 0); - } - - public static RemoteUserAccessRole of(String value) { - return new RemoteUserAccessRole(value, 1); - } - - public interface Visitor { - T visit(AccessRoleEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RemoteUserAccessRole.class); - } - - @java.lang.Override - public RemoteUserAccessRole deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AccessRoleEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/ScheduledInterview.java b/src/main/java/com/merge/api/resources/ats/types/ScheduledInterview.java index eea16eba9..18b32b60f 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ScheduledInterview.java +++ b/src/main/java/com/merge/api/resources/ats/types/ScheduledInterview.java @@ -49,7 +49,7 @@ public final class ScheduledInterview { private final Optional remoteUpdatedAt; - private final Optional status; + private final Optional status; private final Optional remoteWasDeleted; @@ -73,7 +73,7 @@ private ScheduledInterview( Optional endAt, Optional remoteCreatedAt, Optional remoteUpdatedAt, - Optional status, + Optional status, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -208,7 +208,7 @@ public Optional getRemoteUpdatedAt() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -320,7 +320,7 @@ public static final class Builder { private Optional remoteUpdatedAt = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -498,12 +498,12 @@ public Builder remoteUpdatedAt(OffsetDateTime remoteUpdatedAt) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(ScheduledInterviewStatus status) { + public Builder status(ScheduledInterviewStatusEnum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewApplication.java b/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewApplication.java index 7395af595..b4404beef 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewApplication.java +++ b/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewApplication.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer endAt; - private final Optional status; + private final Optional status; private final Optional> integrationParams; @@ -53,7 +53,7 @@ private ScheduledInterviewRequest( Optional location, Optional startAt, Optional endAt, - Optional status, + Optional status, Optional> integrationParams, Optional> linkedAccountParams, Map additionalProperties) { @@ -135,7 +135,7 @@ public Optional getEndAt() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -213,7 +213,7 @@ public static final class Builder { private Optional endAt = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -316,12 +316,12 @@ public Builder endAt(OffsetDateTime endAt) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(ScheduledInterviewRequestStatus status) { + public Builder status(ScheduledInterviewStatusEnum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewRequestApplication.java b/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewRequestApplication.java index b3494ecc0..6bf044016 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewRequestApplication.java +++ b/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewRequestApplication.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ScheduledInterviewStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ScheduledInterviewRequestStatus && equalTo((ScheduledInterviewRequestStatus) other); - } - - private boolean equalTo(ScheduledInterviewRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ScheduledInterviewRequestStatus of(ScheduledInterviewStatusEnum value) { - return new ScheduledInterviewRequestStatus(value, 0); - } - - public static ScheduledInterviewRequestStatus of(String value) { - return new ScheduledInterviewRequestStatus(value, 1); - } - - public interface Visitor { - T visit(ScheduledInterviewStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ScheduledInterviewRequestStatus.class); - } - - @java.lang.Override - public ScheduledInterviewRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ScheduledInterviewStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewStatus.java b/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewStatus.java deleted file mode 100644 index 93c6ccd90..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/ScheduledInterviewStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ScheduledInterviewStatus.Deserializer.class) -public final class ScheduledInterviewStatus { - private final Object value; - - private final int type; - - private ScheduledInterviewStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ScheduledInterviewStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ScheduledInterviewStatus && equalTo((ScheduledInterviewStatus) other); - } - - private boolean equalTo(ScheduledInterviewStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ScheduledInterviewStatus of(ScheduledInterviewStatusEnum value) { - return new ScheduledInterviewStatus(value, 0); - } - - public static ScheduledInterviewStatus of(String value) { - return new ScheduledInterviewStatus(value, 1); - } - - public interface Visitor { - T visit(ScheduledInterviewStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ScheduledInterviewStatus.class); - } - - @java.lang.Override - public ScheduledInterviewStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ScheduledInterviewStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/Scorecard.java b/src/main/java/com/merge/api/resources/ats/types/Scorecard.java index a19e5c736..7eb7c506c 100644 --- a/src/main/java/com/merge/api/resources/ats/types/Scorecard.java +++ b/src/main/java/com/merge/api/resources/ats/types/Scorecard.java @@ -41,7 +41,7 @@ public final class Scorecard { private final Optional submittedAt; - private final Optional overallRecommendation; + private final Optional overallRecommendation; private final Optional remoteWasDeleted; @@ -61,7 +61,7 @@ private Scorecard( Optional interviewer, Optional remoteCreatedAt, Optional submittedAt, - Optional overallRecommendation, + Optional overallRecommendation, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -162,7 +162,7 @@ public Optional getSubmittedAt() { * */ @JsonProperty("overall_recommendation") - public Optional getOverallRecommendation() { + public Optional getOverallRecommendation() { return overallRecommendation; } @@ -258,7 +258,7 @@ public static final class Builder { private Optional submittedAt = Optional.empty(); - private Optional overallRecommendation = Optional.empty(); + private Optional overallRecommendation = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -388,12 +388,12 @@ public Builder submittedAt(OffsetDateTime submittedAt) { } @JsonSetter(value = "overall_recommendation", nulls = Nulls.SKIP) - public Builder overallRecommendation(Optional overallRecommendation) { + public Builder overallRecommendation(Optional overallRecommendation) { this.overallRecommendation = overallRecommendation; return this; } - public Builder overallRecommendation(ScorecardOverallRecommendation overallRecommendation) { + public Builder overallRecommendation(OverallRecommendationEnum overallRecommendation) { this.overallRecommendation = Optional.ofNullable(overallRecommendation); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/ScorecardApplication.java b/src/main/java/com/merge/api/resources/ats/types/ScorecardApplication.java index 1c6529a27..958e501d7 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ScorecardApplication.java +++ b/src/main/java/com/merge/api/resources/ats/types/ScorecardApplication.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ScorecardApplication deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ScorecardApplication deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ScorecardInterview.java b/src/main/java/com/merge/api/resources/ats/types/ScorecardInterview.java index a6aa1cabb..9f86584e2 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ScorecardInterview.java +++ b/src/main/java/com/merge/api/resources/ats/types/ScorecardInterview.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ScorecardInterview deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ScorecardInterview deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ScorecardInterviewer.java b/src/main/java/com/merge/api/resources/ats/types/ScorecardInterviewer.java index f798cda8a..ff79c9a48 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ScorecardInterviewer.java +++ b/src/main/java/com/merge/api/resources/ats/types/ScorecardInterviewer.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ScorecardInterviewer deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ScorecardInterviewer deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ScorecardOverallRecommendation.java b/src/main/java/com/merge/api/resources/ats/types/ScorecardOverallRecommendation.java deleted file mode 100644 index 454b338e2..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/ScorecardOverallRecommendation.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ScorecardOverallRecommendation.Deserializer.class) -public final class ScorecardOverallRecommendation { - private final Object value; - - private final int type; - - private ScorecardOverallRecommendation(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((OverallRecommendationEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ScorecardOverallRecommendation && equalTo((ScorecardOverallRecommendation) other); - } - - private boolean equalTo(ScorecardOverallRecommendation other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ScorecardOverallRecommendation of(OverallRecommendationEnum value) { - return new ScorecardOverallRecommendation(value, 0); - } - - public static ScorecardOverallRecommendation of(String value) { - return new ScorecardOverallRecommendation(value, 1); - } - - public interface Visitor { - T visit(OverallRecommendationEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ScorecardOverallRecommendation.class); - } - - @java.lang.Override - public ScorecardOverallRecommendation deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, OverallRecommendationEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestion.java b/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestion.java index 2cd291d1f..7a7479d98 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestion.java +++ b/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestion.java @@ -37,7 +37,7 @@ public final class ScreeningQuestion { private final Optional title; - private final Optional type; + private final Optional type; private final Optional required; @@ -55,7 +55,7 @@ private ScreeningQuestion( Optional job, Optional description, Optional title, - Optional type, + Optional type, Optional required, Optional> options, Optional remoteWasDeleted, @@ -141,7 +141,7 @@ public Optional getTitle() { * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -232,7 +232,7 @@ public static final class Builder { private Optional title = Optional.empty(); - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); private Optional required = Optional.empty(); @@ -338,12 +338,12 @@ public Builder title(String title) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(ScreeningQuestionType type) { + public Builder type(ScreeningQuestionTypeEnum type) { this.type = Optional.ofNullable(type); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestionAnswerQuestion.java b/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestionAnswerQuestion.java index aa24d5a2e..0a5bf9873 100644 --- a/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestionAnswerQuestion.java +++ b/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestionAnswerQuestion.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ScreeningQuestionJob deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ScreeningQuestionJob deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestionType.java b/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestionType.java deleted file mode 100644 index 37d68c9d5..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/ScreeningQuestionType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ScreeningQuestionType.Deserializer.class) -public final class ScreeningQuestionType { - private final Object value; - - private final int type; - - private ScreeningQuestionType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ScreeningQuestionTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ScreeningQuestionType && equalTo((ScreeningQuestionType) other); - } - - private boolean equalTo(ScreeningQuestionType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ScreeningQuestionType of(ScreeningQuestionTypeEnum value) { - return new ScreeningQuestionType(value, 0); - } - - public static ScreeningQuestionType of(String value) { - return new ScreeningQuestionType(value, 1); - } - - public interface Visitor { - T visit(ScreeningQuestionTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ScreeningQuestionType.class); - } - - @java.lang.Override - public ScreeningQuestionType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ScreeningQuestionTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/StatusFd5Enum.java b/src/main/java/com/merge/api/resources/ats/types/StatusFd5Enum.java new file mode 100644 index 000000000..c1448e7cc --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/types/StatusFd5Enum.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum StatusFd5Enum { + SYNCING("SYNCING"), + + DONE("DONE"), + + FAILED("FAILED"), + + DISABLED("DISABLED"), + + PAUSED("PAUSED"), + + PARTIALLY_SYNCED("PARTIALLY_SYNCED"); + + private final String value; + + StatusFd5Enum(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/types/SyncStatus.java b/src/main/java/com/merge/api/resources/ats/types/SyncStatus.java index 4bb36a817..9891c8264 100644 --- a/src/main/java/com/merge/api/resources/ats/types/SyncStatus.java +++ b/src/main/java/com/merge/api/resources/ats/types/SyncStatus.java @@ -30,7 +30,11 @@ public final class SyncStatus { private final Optional nextSyncStart; - private final SyncStatusStatusEnum status; + private final Optional lastSyncResult; + + private final Optional lastSyncFinished; + + private final StatusFd5Enum status; private final boolean isInitialSync; @@ -43,7 +47,9 @@ private SyncStatus( String modelId, Optional lastSyncStart, Optional nextSyncStart, - SyncStatusStatusEnum status, + Optional lastSyncResult, + Optional lastSyncFinished, + StatusFd5Enum status, boolean isInitialSync, Optional selectiveSyncConfigurationsUsage, Map additionalProperties) { @@ -51,6 +57,8 @@ private SyncStatus( this.modelId = modelId; this.lastSyncStart = lastSyncStart; this.nextSyncStart = nextSyncStart; + this.lastSyncResult = lastSyncResult; + this.lastSyncFinished = lastSyncFinished; this.status = status; this.isInitialSync = isInitialSync; this.selectiveSyncConfigurationsUsage = selectiveSyncConfigurationsUsage; @@ -77,8 +85,18 @@ public Optional getNextSyncStart() { return nextSyncStart; } + @JsonProperty("last_sync_result") + public Optional getLastSyncResult() { + return lastSyncResult; + } + + @JsonProperty("last_sync_finished") + public Optional getLastSyncFinished() { + return lastSyncFinished; + } + @JsonProperty("status") - public SyncStatusStatusEnum getStatus() { + public StatusFd5Enum getStatus() { return status; } @@ -108,6 +126,8 @@ private boolean equalTo(SyncStatus other) { && modelId.equals(other.modelId) && lastSyncStart.equals(other.lastSyncStart) && nextSyncStart.equals(other.nextSyncStart) + && lastSyncResult.equals(other.lastSyncResult) + && lastSyncFinished.equals(other.lastSyncFinished) && status.equals(other.status) && isInitialSync == other.isInitialSync && selectiveSyncConfigurationsUsage.equals(other.selectiveSyncConfigurationsUsage); @@ -120,6 +140,8 @@ public int hashCode() { this.modelId, this.lastSyncStart, this.nextSyncStart, + this.lastSyncResult, + this.lastSyncFinished, this.status, this.isInitialSync, this.selectiveSyncConfigurationsUsage); @@ -145,7 +167,7 @@ public interface ModelIdStage { } public interface StatusStage { - IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status); + IsInitialSyncStage status(@NotNull StatusFd5Enum status); } public interface IsInitialSyncStage { @@ -163,6 +185,14 @@ public interface _FinalStage { _FinalStage nextSyncStart(OffsetDateTime nextSyncStart); + _FinalStage lastSyncResult(Optional lastSyncResult); + + _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult); + + _FinalStage lastSyncFinished(Optional lastSyncFinished); + + _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished); + _FinalStage selectiveSyncConfigurationsUsage( Optional selectiveSyncConfigurationsUsage); @@ -177,12 +207,16 @@ public static final class Builder private String modelId; - private SyncStatusStatusEnum status; + private StatusFd5Enum status; private boolean isInitialSync; private Optional selectiveSyncConfigurationsUsage = Optional.empty(); + private Optional lastSyncFinished = Optional.empty(); + + private Optional lastSyncResult = Optional.empty(); + private Optional nextSyncStart = Optional.empty(); private Optional lastSyncStart = Optional.empty(); @@ -198,6 +232,8 @@ public Builder from(SyncStatus other) { modelId(other.getModelId()); lastSyncStart(other.getLastSyncStart()); nextSyncStart(other.getNextSyncStart()); + lastSyncResult(other.getLastSyncResult()); + lastSyncFinished(other.getLastSyncFinished()); status(other.getStatus()); isInitialSync(other.getIsInitialSync()); selectiveSyncConfigurationsUsage(other.getSelectiveSyncConfigurationsUsage()); @@ -220,7 +256,7 @@ public StatusStage modelId(@NotNull String modelId) { @java.lang.Override @JsonSetter("status") - public IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status) { + public IsInitialSyncStage status(@NotNull StatusFd5Enum status) { this.status = status; return this; } @@ -247,6 +283,32 @@ public _FinalStage selectiveSyncConfigurationsUsage( return this; } + @java.lang.Override + public _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished) { + this.lastSyncFinished = Optional.ofNullable(lastSyncFinished); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_finished", nulls = Nulls.SKIP) + public _FinalStage lastSyncFinished(Optional lastSyncFinished) { + this.lastSyncFinished = lastSyncFinished; + return this; + } + + @java.lang.Override + public _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult) { + this.lastSyncResult = Optional.ofNullable(lastSyncResult); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_result", nulls = Nulls.SKIP) + public _FinalStage lastSyncResult(Optional lastSyncResult) { + this.lastSyncResult = lastSyncResult; + return this; + } + @java.lang.Override public _FinalStage nextSyncStart(OffsetDateTime nextSyncStart) { this.nextSyncStart = Optional.ofNullable(nextSyncStart); @@ -280,6 +342,8 @@ public SyncStatus build() { modelId, lastSyncStart, nextSyncStart, + lastSyncResult, + lastSyncFinished, status, isInitialSync, selectiveSyncConfigurationsUsage, diff --git a/src/main/java/com/merge/api/resources/ats/types/SyncStatusStatusEnum.java b/src/main/java/com/merge/api/resources/ats/types/SyncStatusStatusEnum.java deleted file mode 100644 index b65741a63..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/SyncStatusStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SyncStatusStatusEnum { - SYNCING("SYNCING"), - - DONE("DONE"), - - FAILED("FAILED"), - - DISABLED("DISABLED"), - - PAUSED("PAUSED"), - - PARTIALLY_SYNCED("PARTIALLY_SYNCED"); - - private final String value; - - SyncStatusStatusEnum(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/Url.java b/src/main/java/com/merge/api/resources/ats/types/Url.java index bea0053c6..3f828608d 100644 --- a/src/main/java/com/merge/api/resources/ats/types/Url.java +++ b/src/main/java/com/merge/api/resources/ats/types/Url.java @@ -27,7 +27,7 @@ public final class Url { private final Optional value; - private final Optional urlType; + private final Optional urlType; private final Optional remoteWasDeleted; @@ -37,7 +37,7 @@ private Url( Optional createdAt, Optional modifiedAt, Optional value, - Optional urlType, + Optional urlType, Optional remoteWasDeleted, Map additionalProperties) { this.createdAt = createdAt; @@ -85,7 +85,7 @@ public Optional getValue() { * */ @JsonProperty("url_type") - public Optional getUrlType() { + public Optional getUrlType() { return urlType; } @@ -138,7 +138,7 @@ public static final class Builder { private Optional value = Optional.empty(); - private Optional urlType = Optional.empty(); + private Optional urlType = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -190,12 +190,12 @@ public Builder value(String value) { } @JsonSetter(value = "url_type", nulls = Nulls.SKIP) - public Builder urlType(Optional urlType) { + public Builder urlType(Optional urlType) { this.urlType = urlType; return this; } - public Builder urlType(UrlUrlType urlType) { + public Builder urlType(UrlTypeEnum urlType) { this.urlType = Optional.ofNullable(urlType); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/UrlRequest.java b/src/main/java/com/merge/api/resources/ats/types/UrlRequest.java index ac99f53ed..946df040c 100644 --- a/src/main/java/com/merge/api/resources/ats/types/UrlRequest.java +++ b/src/main/java/com/merge/api/resources/ats/types/UrlRequest.java @@ -23,7 +23,7 @@ public final class UrlRequest { private final Optional value; - private final Optional urlType; + private final Optional urlType; private final Optional> integrationParams; @@ -33,7 +33,7 @@ public final class UrlRequest { private UrlRequest( Optional value, - Optional urlType, + Optional urlType, Optional> integrationParams, Optional> linkedAccountParams, Map additionalProperties) { @@ -65,7 +65,7 @@ public Optional getValue() { * */ @JsonProperty("url_type") - public Optional getUrlType() { + public Optional getUrlType() { return urlType; } @@ -115,7 +115,7 @@ public static Builder builder() { public static final class Builder { private Optional value = Optional.empty(); - private Optional urlType = Optional.empty(); + private Optional urlType = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -146,12 +146,12 @@ public Builder value(String value) { } @JsonSetter(value = "url_type", nulls = Nulls.SKIP) - public Builder urlType(Optional urlType) { + public Builder urlType(Optional urlType) { this.urlType = urlType; return this; } - public Builder urlType(UrlRequestUrlType urlType) { + public Builder urlType(UrlTypeEnum urlType) { this.urlType = Optional.ofNullable(urlType); return this; } diff --git a/src/main/java/com/merge/api/resources/ats/types/UrlRequestUrlType.java b/src/main/java/com/merge/api/resources/ats/types/UrlRequestUrlType.java deleted file mode 100644 index 26f611800..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/UrlRequestUrlType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = UrlRequestUrlType.Deserializer.class) -public final class UrlRequestUrlType { - private final Object value; - - private final int type; - - private UrlRequestUrlType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((UrlTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UrlRequestUrlType && equalTo((UrlRequestUrlType) other); - } - - private boolean equalTo(UrlRequestUrlType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static UrlRequestUrlType of(UrlTypeEnum value) { - return new UrlRequestUrlType(value, 0); - } - - public static UrlRequestUrlType of(String value) { - return new UrlRequestUrlType(value, 1); - } - - public interface Visitor { - T visit(UrlTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(UrlRequestUrlType.class); - } - - @java.lang.Override - public UrlRequestUrlType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, UrlTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/types/UrlUrlType.java b/src/main/java/com/merge/api/resources/ats/types/UrlUrlType.java deleted file mode 100644 index debf6dafb..000000000 --- a/src/main/java/com/merge/api/resources/ats/types/UrlUrlType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ats.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = UrlUrlType.Deserializer.class) -public final class UrlUrlType { - private final Object value; - - private final int type; - - private UrlUrlType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((UrlTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UrlUrlType && equalTo((UrlUrlType) other); - } - - private boolean equalTo(UrlUrlType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static UrlUrlType of(UrlTypeEnum value) { - return new UrlUrlType(value, 0); - } - - public static UrlUrlType of(String value) { - return new UrlUrlType(value, 1); - } - - public interface Visitor { - T visit(UrlTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(UrlUrlType.class); - } - - @java.lang.Override - public UrlUrlType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, UrlTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ats/users/AsyncRawUsersClient.java b/src/main/java/com/merge/api/resources/ats/users/AsyncRawUsersClient.java new file mode 100644 index 000000000..6096c8a2e --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/users/AsyncRawUsersClient.java @@ -0,0 +1,251 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.users; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.PaginatedRemoteUserList; +import com.merge.api.resources.ats.types.RemoteUser; +import com.merge.api.resources.ats.users.requests.UsersListRequest; +import com.merge.api.resources.ats.users.requests.UsersRetrieveRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawUsersClient { + protected final ClientOptions clientOptions; + + public AsyncRawUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of RemoteUser objects. + */ + public CompletableFuture> list() { + return list(UsersListRequest.builder().build()); + } + + /** + * Returns a list of RemoteUser objects. + */ + public CompletableFuture> list(UsersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of RemoteUser objects. + */ + public CompletableFuture> list( + UsersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/users"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email", request.getEmail().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteUserList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a RemoteUser object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, UsersRetrieveRequest.builder().build()); + } + + /** + * Returns a RemoteUser object with the given id. + */ + public CompletableFuture> retrieve(String id, UsersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a RemoteUser object with the given id. + */ + public CompletableFuture> retrieve( + String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/users") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteUser.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/users/AsyncUsersClient.java b/src/main/java/com/merge/api/resources/ats/users/AsyncUsersClient.java new file mode 100644 index 000000000..4931993b2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/users/AsyncUsersClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.users; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.PaginatedRemoteUserList; +import com.merge.api.resources.ats.types.RemoteUser; +import com.merge.api.resources.ats.users.requests.UsersListRequest; +import com.merge.api.resources.ats.users.requests.UsersRetrieveRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncUsersClient { + protected final ClientOptions clientOptions; + + private final AsyncRawUsersClient rawClient; + + public AsyncUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawUsersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawUsersClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of RemoteUser objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteUser objects. + */ + public CompletableFuture list(UsersListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteUser objects. + */ + public CompletableFuture list(UsersListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a RemoteUser object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a RemoteUser object with the given id. + */ + public CompletableFuture retrieve(String id, UsersRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a RemoteUser object with the given id. + */ + public CompletableFuture retrieve( + String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/users/RawUsersClient.java b/src/main/java/com/merge/api/resources/ats/users/RawUsersClient.java new file mode 100644 index 000000000..eb08ed04a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/users/RawUsersClient.java @@ -0,0 +1,218 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.users; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.PaginatedRemoteUserList; +import com.merge.api.resources.ats.types.RemoteUser; +import com.merge.api.resources.ats.users.requests.UsersListRequest; +import com.merge.api.resources.ats.users.requests.UsersRetrieveRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawUsersClient { + protected final ClientOptions clientOptions; + + public RawUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of RemoteUser objects. + */ + public MergeApiHttpResponse list() { + return list(UsersListRequest.builder().build()); + } + + /** + * Returns a list of RemoteUser objects. + */ + public MergeApiHttpResponse list(UsersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of RemoteUser objects. + */ + public MergeApiHttpResponse list(UsersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/users"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email", request.getEmail().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteUserList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a RemoteUser object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, UsersRetrieveRequest.builder().build()); + } + + /** + * Returns a RemoteUser object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, UsersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a RemoteUser object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/users") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteUser.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/users/UsersClient.java b/src/main/java/com/merge/api/resources/ats/users/UsersClient.java index a42894714..905df26a2 100644 --- a/src/main/java/com/merge/api/resources/ats/users/UsersClient.java +++ b/src/main/java/com/merge/api/resources/ats/users/UsersClient.java @@ -3,181 +3,69 @@ */ package com.merge.api.resources.ats.users; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.types.PaginatedRemoteUserList; import com.merge.api.resources.ats.types.RemoteUser; import com.merge.api.resources.ats.users.requests.UsersListRequest; import com.merge.api.resources.ats.users.requests.UsersRetrieveRequest; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class UsersClient { protected final ClientOptions clientOptions; + private final RawUsersClient rawClient; + public UsersClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawUsersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawUsersClient withRawResponse() { + return this.rawClient; } /** * Returns a list of RemoteUser objects. */ public PaginatedRemoteUserList list() { - return list(UsersListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of RemoteUser objects. */ public PaginatedRemoteUserList list(UsersListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of RemoteUser objects. */ public PaginatedRemoteUserList list(UsersListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/users"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmail().isPresent()) { - httpUrl.addQueryParameter("email", request.getEmail().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteUserList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a RemoteUser object with the given id. */ public RemoteUser retrieve(String id) { - return retrieve(id, UsersRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a RemoteUser object with the given id. */ public RemoteUser retrieve(String id, UsersRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a RemoteUser object with the given id. */ public RemoteUser retrieve(String id, UsersRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/users") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteUser.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ats/users/requests/UsersRetrieveRequest.java b/src/main/java/com/merge/api/resources/ats/users/requests/UsersRetrieveRequest.java index 7ec77bfcf..7884b914d 100644 --- a/src/main/java/com/merge/api/resources/ats/users/requests/UsersRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ats/users/requests/UsersRetrieveRequest.java @@ -22,6 +22,8 @@ public final class UsersRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -30,10 +32,12 @@ public final class UsersRetrieveRequest { private UsersRetrieveRequest( Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -47,6 +51,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -76,13 +88,14 @@ public Map getAdditionalProperties() { private boolean equalTo(UsersRetrieveRequest other) { return includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash(this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -98,6 +111,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -109,6 +124,7 @@ private Builder() {} public Builder from(UsersRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; @@ -125,6 +141,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -148,7 +175,8 @@ public Builder showEnumOrigins(String showEnumOrigins) { } public UsersRetrieveRequest build() { - return new UsersRetrieveRequest(includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + return new UsersRetrieveRequest( + includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ats/webhookreceivers/AsyncRawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/ats/webhookreceivers/AsyncRawWebhookReceiversClient.java new file mode 100644 index 000000000..ea4fc61e0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/webhookreceivers/AsyncRawWebhookReceiversClient.java @@ -0,0 +1,160 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.WebhookReceiver; +import com.merge.api.resources.ats.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public AsyncRawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create( + WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ats/webhookreceivers/AsyncWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/ats/webhookreceivers/AsyncWebhookReceiversClient.java new file mode 100644 index 000000000..d629e9278 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/webhookreceivers/AsyncWebhookReceiversClient.java @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.webhookreceivers; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.WebhookReceiver; +import com.merge.api.resources.ats.webhookreceivers.requests.WebhookReceiverRequest; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncWebhookReceiversClient { + protected final ClientOptions clientOptions; + + private final AsyncRawWebhookReceiversClient rawClient; + + public AsyncWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawWebhookReceiversClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ats/webhookreceivers/RawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/ats/webhookreceivers/RawWebhookReceiversClient.java new file mode 100644 index 000000000..6e1347f4a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ats/webhookreceivers/RawWebhookReceiversClient.java @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ats.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ats.types.WebhookReceiver; +import com.merge.api.resources.ats.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public RawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ats/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ats/webhookreceivers/WebhookReceiversClient.java b/src/main/java/com/merge/api/resources/ats/webhookreceivers/WebhookReceiversClient.java index 439cc71b3..3135f4847 100644 --- a/src/main/java/com/merge/api/resources/ats/webhookreceivers/WebhookReceiversClient.java +++ b/src/main/java/com/merge/api/resources/ats/webhookreceivers/WebhookReceiversClient.java @@ -3,120 +3,54 @@ */ package com.merge.api.resources.ats.webhookreceivers; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ats.types.WebhookReceiver; import com.merge.api.resources.ats.webhookreceivers.requests.WebhookReceiverRequest; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class WebhookReceiversClient { protected final ClientOptions clientOptions; + private final RawWebhookReceiversClient rawClient; + public WebhookReceiversClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawWebhookReceiversClient withRawResponse() { + return this.rawClient; } /** * Returns a list of WebhookReceiver objects. */ public List list() { - return list(null); + return this.rawClient.list().body(); } /** * Returns a list of WebhookReceiver objects. */ public List list(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/webhook-receivers") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(requestOptions).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ats/v1/webhook-receivers") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/AsyncCrmClient.java b/src/main/java/com/merge/api/resources/crm/AsyncCrmClient.java new file mode 100644 index 000000000..b2bfeb68e --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/AsyncCrmClient.java @@ -0,0 +1,264 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.Suppliers; +import com.merge.api.resources.crm.accountdetails.AsyncAccountDetailsClient; +import com.merge.api.resources.crm.accounts.AsyncAccountsClient; +import com.merge.api.resources.crm.accounttoken.AsyncAccountTokenClient; +import com.merge.api.resources.crm.associations.AsyncAssociationsClient; +import com.merge.api.resources.crm.associationtypes.AsyncAssociationTypesClient; +import com.merge.api.resources.crm.asyncpassthrough.AsyncAsyncPassthroughClient; +import com.merge.api.resources.crm.audittrail.AsyncAuditTrailClient; +import com.merge.api.resources.crm.availableactions.AsyncAvailableActionsClient; +import com.merge.api.resources.crm.contacts.AsyncContactsClient; +import com.merge.api.resources.crm.customobjectclasses.AsyncCustomObjectClassesClient; +import com.merge.api.resources.crm.customobjects.AsyncCustomObjectsClient; +import com.merge.api.resources.crm.deleteaccount.AsyncDeleteAccountClient; +import com.merge.api.resources.crm.engagements.AsyncEngagementsClient; +import com.merge.api.resources.crm.engagementtypes.AsyncEngagementTypesClient; +import com.merge.api.resources.crm.fieldmapping.AsyncFieldMappingClient; +import com.merge.api.resources.crm.forceresync.AsyncForceResyncClient; +import com.merge.api.resources.crm.generatekey.AsyncGenerateKeyClient; +import com.merge.api.resources.crm.issues.AsyncIssuesClient; +import com.merge.api.resources.crm.leads.AsyncLeadsClient; +import com.merge.api.resources.crm.linkedaccounts.AsyncLinkedAccountsClient; +import com.merge.api.resources.crm.linktoken.AsyncLinkTokenClient; +import com.merge.api.resources.crm.notes.AsyncNotesClient; +import com.merge.api.resources.crm.opportunities.AsyncOpportunitiesClient; +import com.merge.api.resources.crm.passthrough.AsyncPassthroughClient; +import com.merge.api.resources.crm.regeneratekey.AsyncRegenerateKeyClient; +import com.merge.api.resources.crm.scopes.AsyncScopesClient; +import com.merge.api.resources.crm.stages.AsyncStagesClient; +import com.merge.api.resources.crm.syncstatus.AsyncSyncStatusClient; +import com.merge.api.resources.crm.tasks.AsyncTasksClient; +import com.merge.api.resources.crm.users.AsyncUsersClient; +import com.merge.api.resources.crm.webhookreceivers.AsyncWebhookReceiversClient; +import java.util.function.Supplier; + +public class AsyncCrmClient { + protected final ClientOptions clientOptions; + + protected final Supplier accountDetailsClient; + + protected final Supplier accountTokenClient; + + protected final Supplier accountsClient; + + protected final Supplier asyncPassthroughClient; + + protected final Supplier auditTrailClient; + + protected final Supplier availableActionsClient; + + protected final Supplier contactsClient; + + protected final Supplier customObjectClassesClient; + + protected final Supplier associationTypesClient; + + protected final Supplier customObjectsClient; + + protected final Supplier associationsClient; + + protected final Supplier scopesClient; + + protected final Supplier deleteAccountClient; + + protected final Supplier engagementTypesClient; + + protected final Supplier engagementsClient; + + protected final Supplier fieldMappingClient; + + protected final Supplier generateKeyClient; + + protected final Supplier issuesClient; + + protected final Supplier leadsClient; + + protected final Supplier linkTokenClient; + + protected final Supplier linkedAccountsClient; + + protected final Supplier notesClient; + + protected final Supplier opportunitiesClient; + + protected final Supplier passthroughClient; + + protected final Supplier regenerateKeyClient; + + protected final Supplier stagesClient; + + protected final Supplier syncStatusClient; + + protected final Supplier forceResyncClient; + + protected final Supplier tasksClient; + + protected final Supplier usersClient; + + protected final Supplier webhookReceiversClient; + + public AsyncCrmClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.accountDetailsClient = Suppliers.memoize(() -> new AsyncAccountDetailsClient(clientOptions)); + this.accountTokenClient = Suppliers.memoize(() -> new AsyncAccountTokenClient(clientOptions)); + this.accountsClient = Suppliers.memoize(() -> new AsyncAccountsClient(clientOptions)); + this.asyncPassthroughClient = Suppliers.memoize(() -> new AsyncAsyncPassthroughClient(clientOptions)); + this.auditTrailClient = Suppliers.memoize(() -> new AsyncAuditTrailClient(clientOptions)); + this.availableActionsClient = Suppliers.memoize(() -> new AsyncAvailableActionsClient(clientOptions)); + this.contactsClient = Suppliers.memoize(() -> new AsyncContactsClient(clientOptions)); + this.customObjectClassesClient = Suppliers.memoize(() -> new AsyncCustomObjectClassesClient(clientOptions)); + this.associationTypesClient = Suppliers.memoize(() -> new AsyncAssociationTypesClient(clientOptions)); + this.customObjectsClient = Suppliers.memoize(() -> new AsyncCustomObjectsClient(clientOptions)); + this.associationsClient = Suppliers.memoize(() -> new AsyncAssociationsClient(clientOptions)); + this.scopesClient = Suppliers.memoize(() -> new AsyncScopesClient(clientOptions)); + this.deleteAccountClient = Suppliers.memoize(() -> new AsyncDeleteAccountClient(clientOptions)); + this.engagementTypesClient = Suppliers.memoize(() -> new AsyncEngagementTypesClient(clientOptions)); + this.engagementsClient = Suppliers.memoize(() -> new AsyncEngagementsClient(clientOptions)); + this.fieldMappingClient = Suppliers.memoize(() -> new AsyncFieldMappingClient(clientOptions)); + this.generateKeyClient = Suppliers.memoize(() -> new AsyncGenerateKeyClient(clientOptions)); + this.issuesClient = Suppliers.memoize(() -> new AsyncIssuesClient(clientOptions)); + this.leadsClient = Suppliers.memoize(() -> new AsyncLeadsClient(clientOptions)); + this.linkTokenClient = Suppliers.memoize(() -> new AsyncLinkTokenClient(clientOptions)); + this.linkedAccountsClient = Suppliers.memoize(() -> new AsyncLinkedAccountsClient(clientOptions)); + this.notesClient = Suppliers.memoize(() -> new AsyncNotesClient(clientOptions)); + this.opportunitiesClient = Suppliers.memoize(() -> new AsyncOpportunitiesClient(clientOptions)); + this.passthroughClient = Suppliers.memoize(() -> new AsyncPassthroughClient(clientOptions)); + this.regenerateKeyClient = Suppliers.memoize(() -> new AsyncRegenerateKeyClient(clientOptions)); + this.stagesClient = Suppliers.memoize(() -> new AsyncStagesClient(clientOptions)); + this.syncStatusClient = Suppliers.memoize(() -> new AsyncSyncStatusClient(clientOptions)); + this.forceResyncClient = Suppliers.memoize(() -> new AsyncForceResyncClient(clientOptions)); + this.tasksClient = Suppliers.memoize(() -> new AsyncTasksClient(clientOptions)); + this.usersClient = Suppliers.memoize(() -> new AsyncUsersClient(clientOptions)); + this.webhookReceiversClient = Suppliers.memoize(() -> new AsyncWebhookReceiversClient(clientOptions)); + } + + public AsyncAccountDetailsClient accountDetails() { + return this.accountDetailsClient.get(); + } + + public AsyncAccountTokenClient accountToken() { + return this.accountTokenClient.get(); + } + + public AsyncAccountsClient accounts() { + return this.accountsClient.get(); + } + + public AsyncAsyncPassthroughClient asyncPassthrough() { + return this.asyncPassthroughClient.get(); + } + + public AsyncAuditTrailClient auditTrail() { + return this.auditTrailClient.get(); + } + + public AsyncAvailableActionsClient availableActions() { + return this.availableActionsClient.get(); + } + + public AsyncContactsClient contacts() { + return this.contactsClient.get(); + } + + public AsyncCustomObjectClassesClient customObjectClasses() { + return this.customObjectClassesClient.get(); + } + + public AsyncAssociationTypesClient associationTypes() { + return this.associationTypesClient.get(); + } + + public AsyncCustomObjectsClient customObjects() { + return this.customObjectsClient.get(); + } + + public AsyncAssociationsClient associations() { + return this.associationsClient.get(); + } + + public AsyncScopesClient scopes() { + return this.scopesClient.get(); + } + + public AsyncDeleteAccountClient deleteAccount() { + return this.deleteAccountClient.get(); + } + + public AsyncEngagementTypesClient engagementTypes() { + return this.engagementTypesClient.get(); + } + + public AsyncEngagementsClient engagements() { + return this.engagementsClient.get(); + } + + public AsyncFieldMappingClient fieldMapping() { + return this.fieldMappingClient.get(); + } + + public AsyncGenerateKeyClient generateKey() { + return this.generateKeyClient.get(); + } + + public AsyncIssuesClient issues() { + return this.issuesClient.get(); + } + + public AsyncLeadsClient leads() { + return this.leadsClient.get(); + } + + public AsyncLinkTokenClient linkToken() { + return this.linkTokenClient.get(); + } + + public AsyncLinkedAccountsClient linkedAccounts() { + return this.linkedAccountsClient.get(); + } + + public AsyncNotesClient notes() { + return this.notesClient.get(); + } + + public AsyncOpportunitiesClient opportunities() { + return this.opportunitiesClient.get(); + } + + public AsyncPassthroughClient passthrough() { + return this.passthroughClient.get(); + } + + public AsyncRegenerateKeyClient regenerateKey() { + return this.regenerateKeyClient.get(); + } + + public AsyncStagesClient stages() { + return this.stagesClient.get(); + } + + public AsyncSyncStatusClient syncStatus() { + return this.syncStatusClient.get(); + } + + public AsyncForceResyncClient forceResync() { + return this.forceResyncClient.get(); + } + + public AsyncTasksClient tasks() { + return this.tasksClient.get(); + } + + public AsyncUsersClient users() { + return this.usersClient.get(); + } + + public AsyncWebhookReceiversClient webhookReceivers() { + return this.webhookReceiversClient.get(); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/accountdetails/AccountDetailsClient.java b/src/main/java/com/merge/api/resources/crm/accountdetails/AccountDetailsClient.java index 8df39fde2..b2de03f43 100644 --- a/src/main/java/com/merge/api/resources/crm/accountdetails/AccountDetailsClient.java +++ b/src/main/java/com/merge/api/resources/crm/accountdetails/AccountDetailsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.crm.accountdetails; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.types.AccountDetails; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountDetailsClient { protected final ClientOptions clientOptions; + private final RawAccountDetailsClient rawClient; + public AccountDetailsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountDetailsClient withRawResponse() { + return this.rawClient; } /** * Get details for a linked account. */ public AccountDetails retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Get details for a linked account. */ public AccountDetails retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/account-details") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/accountdetails/AsyncAccountDetailsClient.java b/src/main/java/com/merge/api/resources/crm/accountdetails/AsyncAccountDetailsClient.java new file mode 100644 index 000000000..d9e24a0e2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/accountdetails/AsyncAccountDetailsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.accountdetails; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.AccountDetails; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountDetailsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountDetailsClient rawClient; + + public AsyncAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountDetailsClient withRawResponse() { + return this.rawClient; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/accountdetails/AsyncRawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/crm/accountdetails/AsyncRawAccountDetailsClient.java new file mode 100644 index 000000000..10ced7eb3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/accountdetails/AsyncRawAccountDetailsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.AccountDetails; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/accountdetails/RawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/crm/accountdetails/RawAccountDetailsClient.java new file mode 100644 index 000000000..2954ed9e5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/accountdetails/RawAccountDetailsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.AccountDetails; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public RawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/accounts/AccountsClient.java b/src/main/java/com/merge/api/resources/crm/accounts/AccountsClient.java index de3b80c7d..e630b39ec 100644 --- a/src/main/java/com/merge/api/resources/crm/accounts/AccountsClient.java +++ b/src/main/java/com/merge/api/resources/crm/accounts/AccountsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.crm.accounts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.accounts.requests.AccountsListRequest; import com.merge.api.resources.crm.accounts.requests.AccountsRemoteFieldClassesListRequest; @@ -19,244 +15,85 @@ import com.merge.api.resources.crm.types.MetaResponse; import com.merge.api.resources.crm.types.PaginatedAccountList; import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountsClient { protected final ClientOptions clientOptions; + private final RawAccountsClient rawClient; + public AccountsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Account objects. */ public PaginatedAccountList list() { - return list(AccountsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Account objects. */ public PaginatedAccountList list(AccountsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Account objects. */ public PaginatedAccountList list(AccountsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/accounts"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getOwnerId().isPresent()) { - httpUrl.addQueryParameter("owner_id", request.getOwnerId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates an Account object with the given values. */ public CrmAccountResponse create(CrmAccountEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates an Account object with the given values. */ public CrmAccountResponse create(CrmAccountEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/accounts"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmAccountResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Account object with the given id. */ public Account retrieve(String id) { - return retrieve(id, AccountsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Account object with the given id. */ public Account retrieve(String id, AccountsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Account object with the given id. */ public Account retrieve(String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/accounts") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Updates an Account object with the given id. */ public CrmAccountResponse partialUpdate(String id, PatchedCrmAccountEndpointRequest request) { - return partialUpdate(id, request, null); + return this.rawClient.partialUpdate(id, request).body(); } /** @@ -264,148 +101,49 @@ public CrmAccountResponse partialUpdate(String id, PatchedCrmAccountEndpointRequ */ public CrmAccountResponse partialUpdate( String id, PatchedCrmAccountEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/accounts") - .addPathSegment(id); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmAccountResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.partialUpdate(id, request, requestOptions).body(); } /** * Returns metadata for CRMAccount PATCHs. */ public MetaResponse metaPatchRetrieve(String id) { - return metaPatchRetrieve(id, null); + return this.rawClient.metaPatchRetrieve(id).body(); } /** * Returns metadata for CRMAccount PATCHs. */ public MetaResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/accounts/meta/patch") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPatchRetrieve(id, requestOptions).body(); } /** * Returns metadata for CRMAccount POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for CRMAccount POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/accounts/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - AccountsRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(AccountsRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -413,61 +151,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(AccountsRemoteFieldC */ public PaginatedRemoteFieldClassList remoteFieldClassesList( AccountsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/accounts/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/accounts/AsyncAccountsClient.java b/src/main/java/com/merge/api/resources/crm/accounts/AsyncAccountsClient.java new file mode 100644 index 000000000..88d7aac9a --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/accounts/AsyncAccountsClient.java @@ -0,0 +1,160 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.accounts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.accounts.requests.AccountsListRequest; +import com.merge.api.resources.crm.accounts.requests.AccountsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.accounts.requests.AccountsRetrieveRequest; +import com.merge.api.resources.crm.accounts.requests.CrmAccountEndpointRequest; +import com.merge.api.resources.crm.accounts.requests.PatchedCrmAccountEndpointRequest; +import com.merge.api.resources.crm.types.Account; +import com.merge.api.resources.crm.types.CrmAccountResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedAccountList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountsClient rawClient; + + public AsyncAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture list(AccountsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture list(AccountsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Account object with the given values. + */ + public CompletableFuture create(CrmAccountEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Account object with the given values. + */ + public CompletableFuture create( + CrmAccountEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture retrieve(String id, AccountsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture retrieve( + String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates an Account object with the given id. + */ + public CompletableFuture partialUpdate(String id, PatchedCrmAccountEndpointRequest request) { + return this.rawClient.partialUpdate(id, request).thenApply(response -> response.body()); + } + + /** + * Updates an Account object with the given id. + */ + public CompletableFuture partialUpdate( + String id, PatchedCrmAccountEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.partialUpdate(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMAccount PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id) { + return this.rawClient.metaPatchRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMAccount PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id, RequestOptions requestOptions) { + return this.rawClient.metaPatchRetrieve(id, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMAccount POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMAccount POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + AccountsRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + AccountsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/accounts/AsyncRawAccountsClient.java b/src/main/java/com/merge/api/resources/crm/accounts/AsyncRawAccountsClient.java new file mode 100644 index 000000000..35d8b10cb --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/accounts/AsyncRawAccountsClient.java @@ -0,0 +1,645 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.accounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.accounts.requests.AccountsListRequest; +import com.merge.api.resources.crm.accounts.requests.AccountsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.accounts.requests.AccountsRetrieveRequest; +import com.merge.api.resources.crm.accounts.requests.CrmAccountEndpointRequest; +import com.merge.api.resources.crm.accounts.requests.PatchedCrmAccountEndpointRequest; +import com.merge.api.resources.crm.types.Account; +import com.merge.api.resources.crm.types.CrmAccountResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedAccountList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture> list() { + return list(AccountsListRequest.builder().build()); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture> list(AccountsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture> list( + AccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getOwnerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "owner_id", request.getOwnerId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Account object with the given values. + */ + public CompletableFuture> create(CrmAccountEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Account object with the given values. + */ + public CompletableFuture> create( + CrmAccountEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmAccountResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, AccountsRetrieveRequest.builder().build()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture> retrieve(String id, AccountsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture> retrieve( + String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Updates an Account object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedCrmAccountEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates an Account object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedCrmAccountEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmAccountResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for CRMAccount PATCHs. + */ + public CompletableFuture> metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for CRMAccount PATCHs. + */ + public CompletableFuture> metaPatchRetrieve( + String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for CRMAccount POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for CRMAccount POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + AccountsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + AccountsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + AccountsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/accounts/RawAccountsClient.java b/src/main/java/com/merge/api/resources/crm/accounts/RawAccountsClient.java new file mode 100644 index 000000000..db197bb1b --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/accounts/RawAccountsClient.java @@ -0,0 +1,542 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.accounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.accounts.requests.AccountsListRequest; +import com.merge.api.resources.crm.accounts.requests.AccountsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.accounts.requests.AccountsRetrieveRequest; +import com.merge.api.resources.crm.accounts.requests.CrmAccountEndpointRequest; +import com.merge.api.resources.crm.accounts.requests.PatchedCrmAccountEndpointRequest; +import com.merge.api.resources.crm.types.Account; +import com.merge.api.resources.crm.types.CrmAccountResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedAccountList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountsClient { + protected final ClientOptions clientOptions; + + public RawAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Account objects. + */ + public MergeApiHttpResponse list() { + return list(AccountsListRequest.builder().build()); + } + + /** + * Returns a list of Account objects. + */ + public MergeApiHttpResponse list(AccountsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Account objects. + */ + public MergeApiHttpResponse list(AccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getOwnerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "owner_id", request.getOwnerId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Account object with the given values. + */ + public MergeApiHttpResponse create(CrmAccountEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Account object with the given values. + */ + public MergeApiHttpResponse create( + CrmAccountEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmAccountResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Account object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, AccountsRetrieveRequest.builder().build()); + } + + /** + * Returns an Account object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, AccountsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Account object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Updates an Account object with the given id. + */ + public MergeApiHttpResponse partialUpdate(String id, PatchedCrmAccountEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates an Account object with the given id. + */ + public MergeApiHttpResponse partialUpdate( + String id, PatchedCrmAccountEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmAccountResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for CRMAccount PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for CRMAccount PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for CRMAccount POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for CRMAccount POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + AccountsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + AccountsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + AccountsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/accounts/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/accounts/requests/AccountsListRequest.java b/src/main/java/com/merge/api/resources/crm/accounts/requests/AccountsListRequest.java index 90e50a90b..acb1ec55f 100644 --- a/src/main/java/com/merge/api/resources/crm/accounts/requests/AccountsListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/accounts/requests/AccountsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,14 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AccountsListRequest.Builder.class) public final class AccountsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -52,10 +54,10 @@ public final class AccountsListRequest { private final Map additionalProperties; private AccountsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -67,10 +69,10 @@ private AccountsListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -84,6 +86,14 @@ private AccountsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -108,14 +118,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -208,10 +210,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(AccountsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -227,10 +229,10 @@ private boolean equalTo(AccountsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -254,14 +256,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -288,10 +290,10 @@ public static final class Builder { private Builder() {} public Builder from(AccountsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -305,6 +307,22 @@ public Builder from(AccountsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -338,17 +356,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -461,10 +468,10 @@ public Builder remoteId(String remoteId) { public AccountsListRequest build() { return new AccountsListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/crm/accounts/requests/AccountsRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/accounts/requests/AccountsRetrieveRequest.java index bdeff3e2a..a0d687b2b 100644 --- a/src/main/java/com/merge/api/resources/crm/accounts/requests/AccountsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/accounts/requests/AccountsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,22 +22,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AccountsRetrieveRequest.Builder.class) public final class AccountsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private AccountsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -43,7 +49,7 @@ private AccountsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -63,6 +69,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -77,12 +91,13 @@ public Map getAdditionalProperties() { private boolean equalTo(AccountsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -96,12 +111,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -111,20 +128,26 @@ public Builder from(AccountsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -147,8 +170,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public AccountsRetrieveRequest build() { - return new AccountsRetrieveRequest(expand, includeRemoteData, includeRemoteFields, additionalProperties); + return new AccountsRetrieveRequest( + expand, includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/accounttoken/AccountTokenClient.java b/src/main/java/com/merge/api/resources/crm/accounttoken/AccountTokenClient.java index b1bbba148..fd67c293c 100644 --- a/src/main/java/com/merge/api/resources/crm/accounttoken/AccountTokenClient.java +++ b/src/main/java/com/merge/api/resources/crm/accounttoken/AccountTokenClient.java @@ -3,66 +3,38 @@ */ package com.merge.api.resources.crm.accounttoken; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.types.AccountToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountTokenClient { protected final ClientOptions clientOptions; + private final RawAccountTokenClient rawClient; + public AccountTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountTokenClient withRawResponse() { + return this.rawClient; } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken) { - return retrieve(publicToken, null); + return this.rawClient.retrieve(publicToken).body(); } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/account-token") - .addPathSegment(publicToken) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(publicToken, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/accounttoken/AsyncAccountTokenClient.java b/src/main/java/com/merge/api/resources/crm/accounttoken/AsyncAccountTokenClient.java new file mode 100644 index 000000000..d3925f1c8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/accounttoken/AsyncAccountTokenClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.accounttoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.AccountToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountTokenClient rawClient; + + public AsyncAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken) { + return this.rawClient.retrieve(publicToken).thenApply(response -> response.body()); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken, RequestOptions requestOptions) { + return this.rawClient.retrieve(publicToken, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/accounttoken/AsyncRawAccountTokenClient.java b/src/main/java/com/merge/api/resources/crm/accounttoken/AsyncRawAccountTokenClient.java new file mode 100644 index 000000000..3f1595559 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/accounttoken/AsyncRawAccountTokenClient.java @@ -0,0 +1,90 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.AccountToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve( + String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/accounttoken/RawAccountTokenClient.java b/src/main/java/com/merge/api/resources/crm/accounttoken/RawAccountTokenClient.java new file mode 100644 index 000000000..3985ad2df --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/accounttoken/RawAccountTokenClient.java @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.AccountToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountTokenClient { + protected final ClientOptions clientOptions; + + public RawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/associations/AssociationsClient.java b/src/main/java/com/merge/api/resources/crm/associations/AssociationsClient.java index 803d57942..587dd8be5 100644 --- a/src/main/java/com/merge/api/resources/crm/associations/AssociationsClient.java +++ b/src/main/java/com/merge/api/resources/crm/associations/AssociationsClient.java @@ -3,28 +3,28 @@ */ package com.merge.api.resources.crm.associations; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.associations.requests.CustomObjectClassesCustomObjectsAssociationsListRequest; import com.merge.api.resources.crm.associations.requests.CustomObjectClassesCustomObjectsAssociationsUpdateRequest; import com.merge.api.resources.crm.types.Association; import com.merge.api.resources.crm.types.PaginatedAssociationList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AssociationsClient { protected final ClientOptions clientOptions; + private final RawAssociationsClient rawClient; + public AssociationsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAssociationsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAssociationsClient withRawResponse() { + return this.rawClient; } /** @@ -32,11 +32,9 @@ public AssociationsClient(ClientOptions clientOptions) { */ public PaginatedAssociationList customObjectClassesCustomObjectsAssociationsList( String customObjectClassId, String objectId) { - return customObjectClassesCustomObjectsAssociationsList( - customObjectClassId, - objectId, - CustomObjectClassesCustomObjectsAssociationsListRequest.builder() - .build()); + return this.rawClient + .customObjectClassesCustomObjectsAssociationsList(customObjectClassId, objectId) + .body(); } /** @@ -46,7 +44,9 @@ public PaginatedAssociationList customObjectClassesCustomObjectsAssociationsList String customObjectClassId, String objectId, CustomObjectClassesCustomObjectsAssociationsListRequest request) { - return customObjectClassesCustomObjectsAssociationsList(customObjectClassId, objectId, request, null); + return this.rawClient + .customObjectClassesCustomObjectsAssociationsList(customObjectClassId, objectId, request) + .body(); } /** @@ -57,82 +57,10 @@ public PaginatedAssociationList customObjectClassesCustomObjectsAssociationsList String objectId, CustomObjectClassesCustomObjectsAssociationsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(customObjectClassId) - .addPathSegments("custom-objects") - .addPathSegment(objectId) - .addPathSegments("associations"); - if (request.getAssociationTypeId().isPresent()) { - httpUrl.addQueryParameter( - "association_type_id", request.getAssociationTypeId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAssociationList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesCustomObjectsAssociationsList( + customObjectClassId, objectId, request, requestOptions) + .body(); } /** @@ -144,14 +72,10 @@ public Association customObjectClassesCustomObjectsAssociationsUpdate( String sourceObjectId, String targetClassId, String targetObjectId) { - return customObjectClassesCustomObjectsAssociationsUpdate( - associationTypeId, - sourceClassId, - sourceObjectId, - targetClassId, - targetObjectId, - CustomObjectClassesCustomObjectsAssociationsUpdateRequest.builder() - .build()); + return this.rawClient + .customObjectClassesCustomObjectsAssociationsUpdate( + associationTypeId, sourceClassId, sourceObjectId, targetClassId, targetObjectId) + .body(); } /** @@ -164,8 +88,10 @@ public Association customObjectClassesCustomObjectsAssociationsUpdate( String targetClassId, String targetObjectId, CustomObjectClassesCustomObjectsAssociationsUpdateRequest request) { - return customObjectClassesCustomObjectsAssociationsUpdate( - associationTypeId, sourceClassId, sourceObjectId, targetClassId, targetObjectId, request, null); + return this.rawClient + .customObjectClassesCustomObjectsAssociationsUpdate( + associationTypeId, sourceClassId, sourceObjectId, targetClassId, targetObjectId, request) + .body(); } /** @@ -179,46 +105,15 @@ public Association customObjectClassesCustomObjectsAssociationsUpdate( String targetObjectId, CustomObjectClassesCustomObjectsAssociationsUpdateRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(sourceClassId) - .addPathSegments("custom-objects") - .addPathSegment(sourceObjectId) - .addPathSegments("associations") - .addPathSegment(targetClassId) - .addPathSegment(targetObjectId) - .addPathSegment(associationTypeId); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PUT", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Association.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesCustomObjectsAssociationsUpdate( + associationTypeId, + sourceClassId, + sourceObjectId, + targetClassId, + targetObjectId, + request, + requestOptions) + .body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/associations/AsyncAssociationsClient.java b/src/main/java/com/merge/api/resources/crm/associations/AsyncAssociationsClient.java new file mode 100644 index 000000000..a77b9ebf2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/associations/AsyncAssociationsClient.java @@ -0,0 +1,120 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.associations; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.associations.requests.CustomObjectClassesCustomObjectsAssociationsListRequest; +import com.merge.api.resources.crm.associations.requests.CustomObjectClassesCustomObjectsAssociationsUpdateRequest; +import com.merge.api.resources.crm.types.Association; +import com.merge.api.resources.crm.types.PaginatedAssociationList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAssociationsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAssociationsClient rawClient; + + public AsyncAssociationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAssociationsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAssociationsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Association objects. + */ + public CompletableFuture customObjectClassesCustomObjectsAssociationsList( + String customObjectClassId, String objectId) { + return this.rawClient + .customObjectClassesCustomObjectsAssociationsList(customObjectClassId, objectId) + .thenApply(response -> response.body()); + } + + /** + * Returns a list of Association objects. + */ + public CompletableFuture customObjectClassesCustomObjectsAssociationsList( + String customObjectClassId, + String objectId, + CustomObjectClassesCustomObjectsAssociationsListRequest request) { + return this.rawClient + .customObjectClassesCustomObjectsAssociationsList(customObjectClassId, objectId, request) + .thenApply(response -> response.body()); + } + + /** + * Returns a list of Association objects. + */ + public CompletableFuture customObjectClassesCustomObjectsAssociationsList( + String customObjectClassId, + String objectId, + CustomObjectClassesCustomObjectsAssociationsListRequest request, + RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesCustomObjectsAssociationsList( + customObjectClassId, objectId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Creates an Association between source_object_id and target_object_id of type association_type_id. + */ + public CompletableFuture customObjectClassesCustomObjectsAssociationsUpdate( + String associationTypeId, + String sourceClassId, + String sourceObjectId, + String targetClassId, + String targetObjectId) { + return this.rawClient + .customObjectClassesCustomObjectsAssociationsUpdate( + associationTypeId, sourceClassId, sourceObjectId, targetClassId, targetObjectId) + .thenApply(response -> response.body()); + } + + /** + * Creates an Association between source_object_id and target_object_id of type association_type_id. + */ + public CompletableFuture customObjectClassesCustomObjectsAssociationsUpdate( + String associationTypeId, + String sourceClassId, + String sourceObjectId, + String targetClassId, + String targetObjectId, + CustomObjectClassesCustomObjectsAssociationsUpdateRequest request) { + return this.rawClient + .customObjectClassesCustomObjectsAssociationsUpdate( + associationTypeId, sourceClassId, sourceObjectId, targetClassId, targetObjectId, request) + .thenApply(response -> response.body()); + } + + /** + * Creates an Association between source_object_id and target_object_id of type association_type_id. + */ + public CompletableFuture customObjectClassesCustomObjectsAssociationsUpdate( + String associationTypeId, + String sourceClassId, + String sourceObjectId, + String targetClassId, + String targetObjectId, + CustomObjectClassesCustomObjectsAssociationsUpdateRequest request, + RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesCustomObjectsAssociationsUpdate( + associationTypeId, + sourceClassId, + sourceObjectId, + targetClassId, + targetObjectId, + request, + requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/associations/AsyncRawAssociationsClient.java b/src/main/java/com/merge/api/resources/crm/associations/AsyncRawAssociationsClient.java new file mode 100644 index 000000000..00c5dc37a --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/associations/AsyncRawAssociationsClient.java @@ -0,0 +1,285 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.associations; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.associations.requests.CustomObjectClassesCustomObjectsAssociationsListRequest; +import com.merge.api.resources.crm.associations.requests.CustomObjectClassesCustomObjectsAssociationsUpdateRequest; +import com.merge.api.resources.crm.types.Association; +import com.merge.api.resources.crm.types.PaginatedAssociationList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAssociationsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAssociationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Association objects. + */ + public CompletableFuture> + customObjectClassesCustomObjectsAssociationsList(String customObjectClassId, String objectId) { + return customObjectClassesCustomObjectsAssociationsList( + customObjectClassId, + objectId, + CustomObjectClassesCustomObjectsAssociationsListRequest.builder() + .build()); + } + + /** + * Returns a list of Association objects. + */ + public CompletableFuture> + customObjectClassesCustomObjectsAssociationsList( + String customObjectClassId, + String objectId, + CustomObjectClassesCustomObjectsAssociationsListRequest request) { + return customObjectClassesCustomObjectsAssociationsList(customObjectClassId, objectId, request, null); + } + + /** + * Returns a list of Association objects. + */ + public CompletableFuture> + customObjectClassesCustomObjectsAssociationsList( + String customObjectClassId, + String objectId, + CustomObjectClassesCustomObjectsAssociationsListRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("custom-objects") + .addPathSegment(objectId) + .addPathSegments("associations"); + if (request.getAssociationTypeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "association_type_id", + request.getAssociationTypeId().get(), + false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAssociationList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Association between source_object_id and target_object_id of type association_type_id. + */ + public CompletableFuture> customObjectClassesCustomObjectsAssociationsUpdate( + String associationTypeId, + String sourceClassId, + String sourceObjectId, + String targetClassId, + String targetObjectId) { + return customObjectClassesCustomObjectsAssociationsUpdate( + associationTypeId, + sourceClassId, + sourceObjectId, + targetClassId, + targetObjectId, + CustomObjectClassesCustomObjectsAssociationsUpdateRequest.builder() + .build()); + } + + /** + * Creates an Association between source_object_id and target_object_id of type association_type_id. + */ + public CompletableFuture> customObjectClassesCustomObjectsAssociationsUpdate( + String associationTypeId, + String sourceClassId, + String sourceObjectId, + String targetClassId, + String targetObjectId, + CustomObjectClassesCustomObjectsAssociationsUpdateRequest request) { + return customObjectClassesCustomObjectsAssociationsUpdate( + associationTypeId, sourceClassId, sourceObjectId, targetClassId, targetObjectId, request, null); + } + + /** + * Creates an Association between source_object_id and target_object_id of type association_type_id. + */ + public CompletableFuture> customObjectClassesCustomObjectsAssociationsUpdate( + String associationTypeId, + String sourceClassId, + String sourceObjectId, + String targetClassId, + String targetObjectId, + CustomObjectClassesCustomObjectsAssociationsUpdateRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(sourceClassId) + .addPathSegments("custom-objects") + .addPathSegment(sourceObjectId) + .addPathSegments("associations") + .addPathSegment(targetClassId) + .addPathSegment(targetObjectId) + .addPathSegment(associationTypeId); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PUT", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Association.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/associations/RawAssociationsClient.java b/src/main/java/com/merge/api/resources/crm/associations/RawAssociationsClient.java new file mode 100644 index 000000000..f19ecf31d --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/associations/RawAssociationsClient.java @@ -0,0 +1,251 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.associations; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.associations.requests.CustomObjectClassesCustomObjectsAssociationsListRequest; +import com.merge.api.resources.crm.associations.requests.CustomObjectClassesCustomObjectsAssociationsUpdateRequest; +import com.merge.api.resources.crm.types.Association; +import com.merge.api.resources.crm.types.PaginatedAssociationList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAssociationsClient { + protected final ClientOptions clientOptions; + + public RawAssociationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Association objects. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsAssociationsList( + String customObjectClassId, String objectId) { + return customObjectClassesCustomObjectsAssociationsList( + customObjectClassId, + objectId, + CustomObjectClassesCustomObjectsAssociationsListRequest.builder() + .build()); + } + + /** + * Returns a list of Association objects. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsAssociationsList( + String customObjectClassId, + String objectId, + CustomObjectClassesCustomObjectsAssociationsListRequest request) { + return customObjectClassesCustomObjectsAssociationsList(customObjectClassId, objectId, request, null); + } + + /** + * Returns a list of Association objects. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsAssociationsList( + String customObjectClassId, + String objectId, + CustomObjectClassesCustomObjectsAssociationsListRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("custom-objects") + .addPathSegment(objectId) + .addPathSegments("associations"); + if (request.getAssociationTypeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "association_type_id", + request.getAssociationTypeId().get(), + false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAssociationList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Association between source_object_id and target_object_id of type association_type_id. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsAssociationsUpdate( + String associationTypeId, + String sourceClassId, + String sourceObjectId, + String targetClassId, + String targetObjectId) { + return customObjectClassesCustomObjectsAssociationsUpdate( + associationTypeId, + sourceClassId, + sourceObjectId, + targetClassId, + targetObjectId, + CustomObjectClassesCustomObjectsAssociationsUpdateRequest.builder() + .build()); + } + + /** + * Creates an Association between source_object_id and target_object_id of type association_type_id. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsAssociationsUpdate( + String associationTypeId, + String sourceClassId, + String sourceObjectId, + String targetClassId, + String targetObjectId, + CustomObjectClassesCustomObjectsAssociationsUpdateRequest request) { + return customObjectClassesCustomObjectsAssociationsUpdate( + associationTypeId, sourceClassId, sourceObjectId, targetClassId, targetObjectId, request, null); + } + + /** + * Creates an Association between source_object_id and target_object_id of type association_type_id. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsAssociationsUpdate( + String associationTypeId, + String sourceClassId, + String sourceObjectId, + String targetClassId, + String targetObjectId, + CustomObjectClassesCustomObjectsAssociationsUpdateRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(sourceClassId) + .addPathSegments("custom-objects") + .addPathSegment(sourceObjectId) + .addPathSegments("associations") + .addPathSegment(targetClassId) + .addPathSegment(targetObjectId) + .addPathSegment(associationTypeId); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PUT", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Association.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/associations/requests/CustomObjectClassesCustomObjectsAssociationsListRequest.java b/src/main/java/com/merge/api/resources/crm/associations/requests/CustomObjectClassesCustomObjectsAssociationsListRequest.java index afc25d34c..64b2657ee 100644 --- a/src/main/java/com/merge/api/resources/crm/associations/requests/CustomObjectClassesCustomObjectsAssociationsListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/associations/requests/CustomObjectClassesCustomObjectsAssociationsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CustomObjectClassesCustomObjectsAssociationsListRequest.Builder.class) public final class CustomObjectClassesCustomObjectsAssociationsListRequest { + private final Optional> expand; + private final Optional associationTypeId; private final Optional createdAfter; @@ -29,8 +33,6 @@ public final class CustomObjectClassesCustomObjectsAssociationsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -48,11 +50,11 @@ public final class CustomObjectClassesCustomObjectsAssociationsListRequest { private final Map additionalProperties; private CustomObjectClassesCustomObjectsAssociationsListRequest( + Optional> expand, Optional associationTypeId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -61,11 +63,11 @@ private CustomObjectClassesCustomObjectsAssociationsListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.associationTypeId = associationTypeId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -76,6 +78,14 @@ private CustomObjectClassesCustomObjectsAssociationsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return opportunities with this association_type. */ @@ -108,14 +118,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -185,11 +187,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(CustomObjectClassesCustomObjectsAssociationsListRequest other) { - return associationTypeId.equals(other.associationTypeId) + return expand.equals(other.expand) + && associationTypeId.equals(other.associationTypeId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -202,11 +204,11 @@ private boolean equalTo(CustomObjectClassesCustomObjectsAssociationsListRequest @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.associationTypeId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -227,6 +229,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional associationTypeId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -235,8 +239,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -257,11 +259,11 @@ public static final class Builder { private Builder() {} public Builder from(CustomObjectClassesCustomObjectsAssociationsListRequest other) { + expand(other.getExpand()); associationTypeId(other.getAssociationTypeId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -272,6 +274,22 @@ public Builder from(CustomObjectClassesCustomObjectsAssociationsListRequest othe return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "association_type_id", nulls = Nulls.SKIP) public Builder associationTypeId(Optional associationTypeId) { this.associationTypeId = associationTypeId; @@ -316,17 +334,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -406,11 +413,11 @@ public Builder remoteId(String remoteId) { public CustomObjectClassesCustomObjectsAssociationsListRequest build() { return new CustomObjectClassesCustomObjectsAssociationsListRequest( + expand, associationTypeId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/crm/associationtypes/AssociationTypesClient.java b/src/main/java/com/merge/api/resources/crm/associationtypes/AssociationTypesClient.java index 145c5ae89..b0cce64c9 100644 --- a/src/main/java/com/merge/api/resources/crm/associationtypes/AssociationTypesClient.java +++ b/src/main/java/com/merge/api/resources/crm/associationtypes/AssociationTypesClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.crm.associationtypes; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.associationtypes.requests.CrmAssociationTypeEndpointRequest; import com.merge.api.resources.crm.associationtypes.requests.CustomObjectClassesAssociationTypesListRequest; @@ -16,31 +12,31 @@ import com.merge.api.resources.crm.types.CrmAssociationTypeResponse; import com.merge.api.resources.crm.types.MetaResponse; import com.merge.api.resources.crm.types.PaginatedAssociationTypeList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AssociationTypesClient { protected final ClientOptions clientOptions; + private final RawAssociationTypesClient rawClient; + public AssociationTypesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAssociationTypesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAssociationTypesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of AssociationType objects. */ public PaginatedAssociationTypeList customObjectClassesAssociationTypesList(String customObjectClassId) { - return customObjectClassesAssociationTypesList( - customObjectClassId, - CustomObjectClassesAssociationTypesListRequest.builder().build()); + return this.rawClient + .customObjectClassesAssociationTypesList(customObjectClassId) + .body(); } /** @@ -48,7 +44,9 @@ public PaginatedAssociationTypeList customObjectClassesAssociationTypesList(Stri */ public PaginatedAssociationTypeList customObjectClassesAssociationTypesList( String customObjectClassId, CustomObjectClassesAssociationTypesListRequest request) { - return customObjectClassesAssociationTypesList(customObjectClassId, request, null); + return this.rawClient + .customObjectClassesAssociationTypesList(customObjectClassId, request) + .body(); } /** @@ -58,76 +56,9 @@ public PaginatedAssociationTypeList customObjectClassesAssociationTypesList( String customObjectClassId, CustomObjectClassesAssociationTypesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(customObjectClassId) - .addPathSegments("association-types"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAssociationTypeList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesAssociationTypesList(customObjectClassId, request, requestOptions) + .body(); } /** @@ -135,7 +66,9 @@ public PaginatedAssociationTypeList customObjectClassesAssociationTypesList( */ public CrmAssociationTypeResponse customObjectClassesAssociationTypesCreate( String customObjectClassId, CrmAssociationTypeEndpointRequest request) { - return customObjectClassesAssociationTypesCreate(customObjectClassId, request, null); + return this.rawClient + .customObjectClassesAssociationTypesCreate(customObjectClassId, request) + .body(); } /** @@ -143,61 +76,18 @@ public CrmAssociationTypeResponse customObjectClassesAssociationTypesCreate( */ public CrmAssociationTypeResponse customObjectClassesAssociationTypesCreate( String customObjectClassId, CrmAssociationTypeEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(customObjectClassId) - .addPathSegments("association-types"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmAssociationTypeResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesAssociationTypesCreate(customObjectClassId, request, requestOptions) + .body(); } /** * Returns an AssociationType object with the given id. */ public AssociationType customObjectClassesAssociationTypesRetrieve(String customObjectClassId, String id) { - return customObjectClassesAssociationTypesRetrieve( - customObjectClassId, - id, - CustomObjectClassesAssociationTypesRetrieveRequest.builder().build()); + return this.rawClient + .customObjectClassesAssociationTypesRetrieve(customObjectClassId, id) + .body(); } /** @@ -205,7 +95,9 @@ public AssociationType customObjectClassesAssociationTypesRetrieve(String custom */ public AssociationType customObjectClassesAssociationTypesRetrieve( String customObjectClassId, String id, CustomObjectClassesAssociationTypesRetrieveRequest request) { - return customObjectClassesAssociationTypesRetrieve(customObjectClassId, id, request, null); + return this.rawClient + .customObjectClassesAssociationTypesRetrieve(customObjectClassId, id, request) + .body(); } /** @@ -216,50 +108,18 @@ public AssociationType customObjectClassesAssociationTypesRetrieve( String id, CustomObjectClassesAssociationTypesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(customObjectClassId) - .addPathSegments("association-types") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AssociationType.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesAssociationTypesRetrieve(customObjectClassId, id, request, requestOptions) + .body(); } /** * Returns metadata for CRMAssociationType POSTs. */ public MetaResponse customObjectClassesAssociationTypesMetaPostRetrieve(String customObjectClassId) { - return customObjectClassesAssociationTypesMetaPostRetrieve(customObjectClassId, null); + return this.rawClient + .customObjectClassesAssociationTypesMetaPostRetrieve(customObjectClassId) + .body(); } /** @@ -267,35 +127,8 @@ public MetaResponse customObjectClassesAssociationTypesMetaPostRetrieve(String c */ public MetaResponse customObjectClassesAssociationTypesMetaPostRetrieve( String customObjectClassId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(customObjectClassId) - .addPathSegments("association-types/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesAssociationTypesMetaPostRetrieve(customObjectClassId, requestOptions) + .body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/associationtypes/AsyncAssociationTypesClient.java b/src/main/java/com/merge/api/resources/crm/associationtypes/AsyncAssociationTypesClient.java new file mode 100644 index 000000000..3c5c410d4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/associationtypes/AsyncAssociationTypesClient.java @@ -0,0 +1,138 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.associationtypes; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.associationtypes.requests.CrmAssociationTypeEndpointRequest; +import com.merge.api.resources.crm.associationtypes.requests.CustomObjectClassesAssociationTypesListRequest; +import com.merge.api.resources.crm.associationtypes.requests.CustomObjectClassesAssociationTypesRetrieveRequest; +import com.merge.api.resources.crm.types.AssociationType; +import com.merge.api.resources.crm.types.CrmAssociationTypeResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedAssociationTypeList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAssociationTypesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAssociationTypesClient rawClient; + + public AsyncAssociationTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAssociationTypesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAssociationTypesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of AssociationType objects. + */ + public CompletableFuture customObjectClassesAssociationTypesList( + String customObjectClassId) { + return this.rawClient + .customObjectClassesAssociationTypesList(customObjectClassId) + .thenApply(response -> response.body()); + } + + /** + * Returns a list of AssociationType objects. + */ + public CompletableFuture customObjectClassesAssociationTypesList( + String customObjectClassId, CustomObjectClassesAssociationTypesListRequest request) { + return this.rawClient + .customObjectClassesAssociationTypesList(customObjectClassId, request) + .thenApply(response -> response.body()); + } + + /** + * Returns a list of AssociationType objects. + */ + public CompletableFuture customObjectClassesAssociationTypesList( + String customObjectClassId, + CustomObjectClassesAssociationTypesListRequest request, + RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesAssociationTypesList(customObjectClassId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Creates an AssociationType object with the given values. + */ + public CompletableFuture customObjectClassesAssociationTypesCreate( + String customObjectClassId, CrmAssociationTypeEndpointRequest request) { + return this.rawClient + .customObjectClassesAssociationTypesCreate(customObjectClassId, request) + .thenApply(response -> response.body()); + } + + /** + * Creates an AssociationType object with the given values. + */ + public CompletableFuture customObjectClassesAssociationTypesCreate( + String customObjectClassId, CrmAssociationTypeEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesAssociationTypesCreate(customObjectClassId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns an AssociationType object with the given id. + */ + public CompletableFuture customObjectClassesAssociationTypesRetrieve( + String customObjectClassId, String id) { + return this.rawClient + .customObjectClassesAssociationTypesRetrieve(customObjectClassId, id) + .thenApply(response -> response.body()); + } + + /** + * Returns an AssociationType object with the given id. + */ + public CompletableFuture customObjectClassesAssociationTypesRetrieve( + String customObjectClassId, String id, CustomObjectClassesAssociationTypesRetrieveRequest request) { + return this.rawClient + .customObjectClassesAssociationTypesRetrieve(customObjectClassId, id, request) + .thenApply(response -> response.body()); + } + + /** + * Returns an AssociationType object with the given id. + */ + public CompletableFuture customObjectClassesAssociationTypesRetrieve( + String customObjectClassId, + String id, + CustomObjectClassesAssociationTypesRetrieveRequest request, + RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesAssociationTypesRetrieve(customObjectClassId, id, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMAssociationType POSTs. + */ + public CompletableFuture customObjectClassesAssociationTypesMetaPostRetrieve( + String customObjectClassId) { + return this.rawClient + .customObjectClassesAssociationTypesMetaPostRetrieve(customObjectClassId) + .thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMAssociationType POSTs. + */ + public CompletableFuture customObjectClassesAssociationTypesMetaPostRetrieve( + String customObjectClassId, RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesAssociationTypesMetaPostRetrieve(customObjectClassId, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/associationtypes/AsyncRawAssociationTypesClient.java b/src/main/java/com/merge/api/resources/crm/associationtypes/AsyncRawAssociationTypesClient.java new file mode 100644 index 000000000..58cc6517c --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/associationtypes/AsyncRawAssociationTypesClient.java @@ -0,0 +1,409 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.associationtypes; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.associationtypes.requests.CrmAssociationTypeEndpointRequest; +import com.merge.api.resources.crm.associationtypes.requests.CustomObjectClassesAssociationTypesListRequest; +import com.merge.api.resources.crm.associationtypes.requests.CustomObjectClassesAssociationTypesRetrieveRequest; +import com.merge.api.resources.crm.types.AssociationType; +import com.merge.api.resources.crm.types.CrmAssociationTypeResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedAssociationTypeList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAssociationTypesClient { + protected final ClientOptions clientOptions; + + public AsyncRawAssociationTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of AssociationType objects. + */ + public CompletableFuture> + customObjectClassesAssociationTypesList(String customObjectClassId) { + return customObjectClassesAssociationTypesList( + customObjectClassId, + CustomObjectClassesAssociationTypesListRequest.builder().build()); + } + + /** + * Returns a list of AssociationType objects. + */ + public CompletableFuture> + customObjectClassesAssociationTypesList( + String customObjectClassId, CustomObjectClassesAssociationTypesListRequest request) { + return customObjectClassesAssociationTypesList(customObjectClassId, request, null); + } + + /** + * Returns a list of AssociationType objects. + */ + public CompletableFuture> + customObjectClassesAssociationTypesList( + String customObjectClassId, + CustomObjectClassesAssociationTypesListRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("association-types"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAssociationTypeList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an AssociationType object with the given values. + */ + public CompletableFuture> + customObjectClassesAssociationTypesCreate( + String customObjectClassId, CrmAssociationTypeEndpointRequest request) { + return customObjectClassesAssociationTypesCreate(customObjectClassId, request, null); + } + + /** + * Creates an AssociationType object with the given values. + */ + public CompletableFuture> + customObjectClassesAssociationTypesCreate( + String customObjectClassId, + CrmAssociationTypeEndpointRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("association-types"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CrmAssociationTypeResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an AssociationType object with the given id. + */ + public CompletableFuture> customObjectClassesAssociationTypesRetrieve( + String customObjectClassId, String id) { + return customObjectClassesAssociationTypesRetrieve( + customObjectClassId, + id, + CustomObjectClassesAssociationTypesRetrieveRequest.builder().build()); + } + + /** + * Returns an AssociationType object with the given id. + */ + public CompletableFuture> customObjectClassesAssociationTypesRetrieve( + String customObjectClassId, String id, CustomObjectClassesAssociationTypesRetrieveRequest request) { + return customObjectClassesAssociationTypesRetrieve(customObjectClassId, id, request, null); + } + + /** + * Returns an AssociationType object with the given id. + */ + public CompletableFuture> customObjectClassesAssociationTypesRetrieve( + String customObjectClassId, + String id, + CustomObjectClassesAssociationTypesRetrieveRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("association-types") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AssociationType.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for CRMAssociationType POSTs. + */ + public CompletableFuture> customObjectClassesAssociationTypesMetaPostRetrieve( + String customObjectClassId) { + return customObjectClassesAssociationTypesMetaPostRetrieve(customObjectClassId, null); + } + + /** + * Returns metadata for CRMAssociationType POSTs. + */ + public CompletableFuture> customObjectClassesAssociationTypesMetaPostRetrieve( + String customObjectClassId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("association-types/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/associationtypes/RawAssociationTypesClient.java b/src/main/java/com/merge/api/resources/crm/associationtypes/RawAssociationTypesClient.java new file mode 100644 index 000000000..5c484aa93 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/associationtypes/RawAssociationTypesClient.java @@ -0,0 +1,343 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.associationtypes; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.associationtypes.requests.CrmAssociationTypeEndpointRequest; +import com.merge.api.resources.crm.associationtypes.requests.CustomObjectClassesAssociationTypesListRequest; +import com.merge.api.resources.crm.associationtypes.requests.CustomObjectClassesAssociationTypesRetrieveRequest; +import com.merge.api.resources.crm.types.AssociationType; +import com.merge.api.resources.crm.types.CrmAssociationTypeResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedAssociationTypeList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAssociationTypesClient { + protected final ClientOptions clientOptions; + + public RawAssociationTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of AssociationType objects. + */ + public MergeApiHttpResponse customObjectClassesAssociationTypesList( + String customObjectClassId) { + return customObjectClassesAssociationTypesList( + customObjectClassId, + CustomObjectClassesAssociationTypesListRequest.builder().build()); + } + + /** + * Returns a list of AssociationType objects. + */ + public MergeApiHttpResponse customObjectClassesAssociationTypesList( + String customObjectClassId, CustomObjectClassesAssociationTypesListRequest request) { + return customObjectClassesAssociationTypesList(customObjectClassId, request, null); + } + + /** + * Returns a list of AssociationType objects. + */ + public MergeApiHttpResponse customObjectClassesAssociationTypesList( + String customObjectClassId, + CustomObjectClassesAssociationTypesListRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("association-types"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAssociationTypeList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an AssociationType object with the given values. + */ + public MergeApiHttpResponse customObjectClassesAssociationTypesCreate( + String customObjectClassId, CrmAssociationTypeEndpointRequest request) { + return customObjectClassesAssociationTypesCreate(customObjectClassId, request, null); + } + + /** + * Creates an AssociationType object with the given values. + */ + public MergeApiHttpResponse customObjectClassesAssociationTypesCreate( + String customObjectClassId, CrmAssociationTypeEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("association-types"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmAssociationTypeResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an AssociationType object with the given id. + */ + public MergeApiHttpResponse customObjectClassesAssociationTypesRetrieve( + String customObjectClassId, String id) { + return customObjectClassesAssociationTypesRetrieve( + customObjectClassId, + id, + CustomObjectClassesAssociationTypesRetrieveRequest.builder().build()); + } + + /** + * Returns an AssociationType object with the given id. + */ + public MergeApiHttpResponse customObjectClassesAssociationTypesRetrieve( + String customObjectClassId, String id, CustomObjectClassesAssociationTypesRetrieveRequest request) { + return customObjectClassesAssociationTypesRetrieve(customObjectClassId, id, request, null); + } + + /** + * Returns an AssociationType object with the given id. + */ + public MergeApiHttpResponse customObjectClassesAssociationTypesRetrieve( + String customObjectClassId, + String id, + CustomObjectClassesAssociationTypesRetrieveRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("association-types") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AssociationType.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for CRMAssociationType POSTs. + */ + public MergeApiHttpResponse customObjectClassesAssociationTypesMetaPostRetrieve( + String customObjectClassId) { + return customObjectClassesAssociationTypesMetaPostRetrieve(customObjectClassId, null); + } + + /** + * Returns metadata for CRMAssociationType POSTs. + */ + public MergeApiHttpResponse customObjectClassesAssociationTypesMetaPostRetrieve( + String customObjectClassId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("association-types/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/associationtypes/requests/CustomObjectClassesAssociationTypesListRequest.java b/src/main/java/com/merge/api/resources/crm/associationtypes/requests/CustomObjectClassesAssociationTypesListRequest.java index 35d9653b4..00cbe61b7 100644 --- a/src/main/java/com/merge/api/resources/crm/associationtypes/requests/CustomObjectClassesAssociationTypesListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/associationtypes/requests/CustomObjectClassesAssociationTypesListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,14 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CustomObjectClassesAssociationTypesListRequest.Builder.class) public final class CustomObjectClassesAssociationTypesListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -46,10 +48,10 @@ public final class CustomObjectClassesAssociationTypesListRequest { private final Map additionalProperties; private CustomObjectClassesAssociationTypesListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -58,10 +60,10 @@ private CustomObjectClassesAssociationTypesListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -72,6 +74,14 @@ private CustomObjectClassesAssociationTypesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -96,14 +106,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -173,10 +175,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(CustomObjectClassesAssociationTypesListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -189,10 +191,10 @@ private boolean equalTo(CustomObjectClassesAssociationTypesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -213,14 +215,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -241,10 +243,10 @@ public static final class Builder { private Builder() {} public Builder from(CustomObjectClassesAssociationTypesListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -255,6 +257,22 @@ public Builder from(CustomObjectClassesAssociationTypesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -288,17 +306,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -378,10 +385,10 @@ public Builder remoteId(String remoteId) { public CustomObjectClassesAssociationTypesListRequest build() { return new CustomObjectClassesAssociationTypesListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/crm/associationtypes/requests/CustomObjectClassesAssociationTypesRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/associationtypes/requests/CustomObjectClassesAssociationTypesRetrieveRequest.java index 9aa3d0894..d86f8155d 100644 --- a/src/main/java/com/merge/api/resources/crm/associationtypes/requests/CustomObjectClassesAssociationTypesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/associationtypes/requests/CustomObjectClassesAssociationTypesRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CustomObjectClassesAssociationTypesRetrieveRequest.Builder.class) public final class CustomObjectClassesAssociationTypesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private CustomObjectClassesAssociationTypesRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private CustomObjectClassesAssociationTypesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -62,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(CustomObjectClassesAssociationTypesRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -81,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -93,20 +113,26 @@ private Builder() {} public Builder from(CustomObjectClassesAssociationTypesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -118,9 +144,20 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public CustomObjectClassesAssociationTypesRetrieveRequest build() { return new CustomObjectClassesAssociationTypesRetrieveRequest( - expand, includeRemoteData, additionalProperties); + expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncAsyncPassthroughClient.java new file mode 100644 index 000000000..98b6cc4a0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncAsyncPassthroughClient.java @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.asyncpassthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.crm.types.AsyncPassthroughReciept; +import com.merge.api.resources.crm.types.DataPassthroughRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAsyncPassthroughClient rawClient; + + public AsyncAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAsyncPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create( + DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve(String asyncPassthroughReceiptId) { + return this.rawClient.retrieve(asyncPassthroughReceiptId).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncPassthroughClient.java index e5f41a231..69b2f2f4e 100644 --- a/src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncPassthroughClient.java +++ b/src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncPassthroughClient.java @@ -3,119 +3,56 @@ */ package com.merge.api.resources.crm.asyncpassthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; import com.merge.api.resources.crm.types.AsyncPassthroughReciept; import com.merge.api.resources.crm.types.DataPassthroughRequest; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AsyncPassthroughClient { protected final ClientOptions clientOptions; + private final RawAsyncPassthroughClient rawClient; + public AsyncPassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAsyncPassthroughClient withRawResponse() { + return this.rawClient; } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/async-passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId) { - return retrieve(asyncPassthroughReceiptId, null); + return this.rawClient.retrieve(asyncPassthroughReceiptId).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/async-passthrough") - .addPathSegment(asyncPassthroughReceiptId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), AsyncPassthroughRetrieveResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncRawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncRawAsyncPassthroughClient.java new file mode 100644 index 000000000..a8a90b382 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncRawAsyncPassthroughClient.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.crm.types.AsyncPassthroughReciept; +import com.merge.api.resources.crm.types.DataPassthroughRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughReciept.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/asyncpassthrough/RawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/crm/asyncpassthrough/RawAsyncPassthroughClient.java new file mode 100644 index 000000000..a616395da --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/asyncpassthrough/RawAsyncPassthroughClient.java @@ -0,0 +1,131 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.crm.types.AsyncPassthroughReciept; +import com.merge.api.resources.crm.types.DataPassthroughRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public RawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve(String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java b/src/main/java/com/merge/api/resources/crm/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java index 1142a6bcb..d9db3e6fa 100644 --- a/src/main/java/com/merge/api/resources/crm/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java +++ b/src/main/java/com/merge/api/resources/crm/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java @@ -30,6 +30,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((RemoteResponse) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list(AuditTrailListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list( + AuditTrailListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/audittrail/AsyncRawAuditTrailClient.java b/src/main/java/com/merge/api/resources/crm/audittrail/AsyncRawAuditTrailClient.java new file mode 100644 index 000000000..e11ea4190 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/audittrail/AsyncRawAuditTrailClient.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.crm.types.PaginatedAuditLogEventList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAuditTrailClient { + protected final ClientOptions clientOptions; + + public AsyncRawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAuditLogEventList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/audittrail/AuditTrailClient.java b/src/main/java/com/merge/api/resources/crm/audittrail/AuditTrailClient.java index 03b06c63e..ad1e65a72 100644 --- a/src/main/java/com/merge/api/resources/crm/audittrail/AuditTrailClient.java +++ b/src/main/java/com/merge/api/resources/crm/audittrail/AuditTrailClient.java @@ -3,90 +3,46 @@ */ package com.merge.api.resources.crm.audittrail; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.audittrail.requests.AuditTrailListRequest; import com.merge.api.resources.crm.types.PaginatedAuditLogEventList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AuditTrailClient { protected final ClientOptions clientOptions; + private final RawAuditTrailClient rawClient; + public AuditTrailClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAuditTrailClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAuditTrailClient withRawResponse() { + return this.rawClient; } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list() { - return list(AuditTrailListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/audit-trail"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEventType().isPresent()) { - httpUrl.addQueryParameter("event_type", request.getEventType().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getUserEmail().isPresent()) { - httpUrl.addQueryParameter("user_email", request.getUserEmail().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/audittrail/RawAuditTrailClient.java b/src/main/java/com/merge/api/resources/crm/audittrail/RawAuditTrailClient.java new file mode 100644 index 000000000..be2a7f75a --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/audittrail/RawAuditTrailClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.crm.types.PaginatedAuditLogEventList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAuditTrailClient { + protected final ClientOptions clientOptions; + + public RawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/audittrail/requests/AuditTrailListRequest.java b/src/main/java/com/merge/api/resources/crm/audittrail/requests/AuditTrailListRequest.java index 7a4fdb54e..030cbc3e9 100644 --- a/src/main/java/com/merge/api/resources/crm/audittrail/requests/AuditTrailListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/audittrail/requests/AuditTrailListRequest.java @@ -68,7 +68,7 @@ public Optional getEndDate() { } /** - * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED + * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED */ @JsonProperty("event_type") public Optional getEventType() { diff --git a/src/main/java/com/merge/api/resources/crm/availableactions/AsyncAvailableActionsClient.java b/src/main/java/com/merge/api/resources/crm/availableactions/AsyncAvailableActionsClient.java new file mode 100644 index 000000000..d7d31a6df --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/availableactions/AsyncAvailableActionsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.availableactions; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.AvailableActions; +import java.util.concurrent.CompletableFuture; + +public class AsyncAvailableActionsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAvailableActionsClient rawClient; + + public AsyncAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAvailableActionsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/availableactions/AsyncRawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/crm/availableactions/AsyncRawAvailableActionsClient.java new file mode 100644 index 000000000..d70a1aa15 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/availableactions/AsyncRawAvailableActionsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.AvailableActions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/availableactions/AvailableActionsClient.java b/src/main/java/com/merge/api/resources/crm/availableactions/AvailableActionsClient.java index abef2ce0e..96a5a828e 100644 --- a/src/main/java/com/merge/api/resources/crm/availableactions/AvailableActionsClient.java +++ b/src/main/java/com/merge/api/resources/crm/availableactions/AvailableActionsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.crm.availableactions; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.types.AvailableActions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AvailableActionsClient { protected final ClientOptions clientOptions; + private final RawAvailableActionsClient rawClient; + public AvailableActionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAvailableActionsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/available-actions") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/availableactions/RawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/crm/availableactions/RawAvailableActionsClient.java new file mode 100644 index 000000000..ef0da6c7e --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/availableactions/RawAvailableActionsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.AvailableActions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public RawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/contacts/AsyncContactsClient.java b/src/main/java/com/merge/api/resources/crm/contacts/AsyncContactsClient.java new file mode 100644 index 000000000..3bf7acffd --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/contacts/AsyncContactsClient.java @@ -0,0 +1,176 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.contacts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.contacts.requests.ContactsListRequest; +import com.merge.api.resources.crm.contacts.requests.ContactsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.contacts.requests.ContactsRetrieveRequest; +import com.merge.api.resources.crm.contacts.requests.CrmContactEndpointRequest; +import com.merge.api.resources.crm.contacts.requests.PatchedCrmContactEndpointRequest; +import com.merge.api.resources.crm.types.Contact; +import com.merge.api.resources.crm.types.CrmContactResponse; +import com.merge.api.resources.crm.types.IgnoreCommonModelRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedContactList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncContactsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawContactsClient rawClient; + + public AsyncContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawContactsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawContactsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture list(ContactsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture list(ContactsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture create(CrmContactEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture create( + CrmContactEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture retrieve(String id, ContactsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture retrieve( + String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates a Contact object with the given id. + */ + public CompletableFuture partialUpdate(String id, PatchedCrmContactEndpointRequest request) { + return this.rawClient.partialUpdate(id, request).thenApply(response -> response.body()); + } + + /** + * Updates a Contact object with the given id. + */ + public CompletableFuture partialUpdate( + String id, PatchedCrmContactEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.partialUpdate(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture ignoreCreate(String modelId, IgnoreCommonModelRequest request) { + return this.rawClient.ignoreCreate(modelId, request).thenApply(response -> response.body()); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + return this.rawClient.ignoreCreate(modelId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMContact PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id) { + return this.rawClient.metaPatchRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMContact PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id, RequestOptions requestOptions) { + return this.rawClient.metaPatchRetrieve(id, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMContact POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMContact POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/contacts/AsyncRawContactsClient.java b/src/main/java/com/merge/api/resources/crm/contacts/AsyncRawContactsClient.java new file mode 100644 index 000000000..0270528d4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/contacts/AsyncRawContactsClient.java @@ -0,0 +1,715 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.contacts; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.contacts.requests.ContactsListRequest; +import com.merge.api.resources.crm.contacts.requests.ContactsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.contacts.requests.ContactsRetrieveRequest; +import com.merge.api.resources.crm.contacts.requests.CrmContactEndpointRequest; +import com.merge.api.resources.crm.contacts.requests.PatchedCrmContactEndpointRequest; +import com.merge.api.resources.crm.types.Contact; +import com.merge.api.resources.crm.types.CrmContactResponse; +import com.merge.api.resources.crm.types.IgnoreCommonModelRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedContactList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawContactsClient { + protected final ClientOptions clientOptions; + + public AsyncRawContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture> list() { + return list(ContactsListRequest.builder().build()); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture> list(ContactsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture> list( + ContactsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts"); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmailAddresses().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email_addresses", request.getEmailAddresses().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPhoneNumbers().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "phone_numbers", request.getPhoneNumbers().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedContactList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture> create(CrmContactEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture> create( + CrmContactEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmContactResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, ContactsRetrieveRequest.builder().build()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture> retrieve(String id, ContactsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture> retrieve( + String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Updates a Contact object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedCrmContactEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates a Contact object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedCrmContactEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmContactResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture> ignoreCreate( + String modelId, IgnoreCommonModelRequest request) { + return ignoreCreate(modelId, request, null); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture> ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts/ignore") + .addPathSegment(modelId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for CRMContact PATCHs. + */ + public CompletableFuture> metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for CRMContact PATCHs. + */ + public CompletableFuture> metaPatchRetrieve( + String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for CRMContact POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for CRMContact POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/contacts/ContactsClient.java b/src/main/java/com/merge/api/resources/crm/contacts/ContactsClient.java index af8d47fdf..a56664584 100644 --- a/src/main/java/com/merge/api/resources/crm/contacts/ContactsClient.java +++ b/src/main/java/com/merge/api/resources/crm/contacts/ContactsClient.java @@ -3,12 +3,7 @@ */ package com.merge.api.resources.crm.contacts; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.contacts.requests.ContactsListRequest; import com.merge.api.resources.crm.contacts.requests.ContactsRemoteFieldClassesListRequest; @@ -21,248 +16,85 @@ import com.merge.api.resources.crm.types.MetaResponse; import com.merge.api.resources.crm.types.PaginatedContactList; import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ContactsClient { protected final ClientOptions clientOptions; + private final RawContactsClient rawClient; + public ContactsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawContactsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawContactsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Contact objects. */ public PaginatedContactList list() { - return list(ContactsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Contact objects. */ public PaginatedContactList list(ContactsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Contact objects. */ public PaginatedContactList list(ContactsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/contacts"); - if (request.getAccountId().isPresent()) { - httpUrl.addQueryParameter("account_id", request.getAccountId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmailAddresses().isPresent()) { - httpUrl.addQueryParameter( - "email_addresses", request.getEmailAddresses().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getPhoneNumbers().isPresent()) { - httpUrl.addQueryParameter("phone_numbers", request.getPhoneNumbers().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedContactList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Contact object with the given values. */ public CrmContactResponse create(CrmContactEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Contact object with the given values. */ public CrmContactResponse create(CrmContactEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/contacts"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmContactResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Contact object with the given id. */ public Contact retrieve(String id) { - return retrieve(id, ContactsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Contact object with the given id. */ public Contact retrieve(String id, ContactsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Contact object with the given id. */ public Contact retrieve(String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/contacts") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Updates a Contact object with the given id. */ public CrmContactResponse partialUpdate(String id, PatchedCrmContactEndpointRequest request) { - return partialUpdate(id, request, null); + return this.rawClient.partialUpdate(id, request).body(); } /** @@ -270,196 +102,63 @@ public CrmContactResponse partialUpdate(String id, PatchedCrmContactEndpointRequ */ public CrmContactResponse partialUpdate( String id, PatchedCrmContactEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/contacts") - .addPathSegment(id); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmContactResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.partialUpdate(id, request, requestOptions).body(); } /** * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. */ public void ignoreCreate(String modelId, IgnoreCommonModelRequest request) { - ignoreCreate(modelId, request, null); + this.rawClient.ignoreCreate(modelId, request).body(); } /** * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. */ public void ignoreCreate(String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/contacts/ignore") - .addPathSegment(modelId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + this.rawClient.ignoreCreate(modelId, request, requestOptions).body(); } /** * Returns metadata for CRMContact PATCHs. */ public MetaResponse metaPatchRetrieve(String id) { - return metaPatchRetrieve(id, null); + return this.rawClient.metaPatchRetrieve(id).body(); } /** * Returns metadata for CRMContact PATCHs. */ public MetaResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/contacts/meta/patch") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPatchRetrieve(id, requestOptions).body(); } /** * Returns metadata for CRMContact POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for CRMContact POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/contacts/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - ContactsRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(ContactsRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -467,61 +166,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(ContactsRemoteFieldC */ public PaginatedRemoteFieldClassList remoteFieldClassesList( ContactsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/contacts/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/contacts/RawContactsClient.java b/src/main/java/com/merge/api/resources/crm/contacts/RawContactsClient.java new file mode 100644 index 000000000..330c0f941 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/contacts/RawContactsClient.java @@ -0,0 +1,598 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.contacts; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.contacts.requests.ContactsListRequest; +import com.merge.api.resources.crm.contacts.requests.ContactsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.contacts.requests.ContactsRetrieveRequest; +import com.merge.api.resources.crm.contacts.requests.CrmContactEndpointRequest; +import com.merge.api.resources.crm.contacts.requests.PatchedCrmContactEndpointRequest; +import com.merge.api.resources.crm.types.Contact; +import com.merge.api.resources.crm.types.CrmContactResponse; +import com.merge.api.resources.crm.types.IgnoreCommonModelRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedContactList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawContactsClient { + protected final ClientOptions clientOptions; + + public RawContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Contact objects. + */ + public MergeApiHttpResponse list() { + return list(ContactsListRequest.builder().build()); + } + + /** + * Returns a list of Contact objects. + */ + public MergeApiHttpResponse list(ContactsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Contact objects. + */ + public MergeApiHttpResponse list(ContactsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts"); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmailAddresses().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email_addresses", request.getEmailAddresses().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPhoneNumbers().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "phone_numbers", request.getPhoneNumbers().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedContactList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Contact object with the given values. + */ + public MergeApiHttpResponse create(CrmContactEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Contact object with the given values. + */ + public MergeApiHttpResponse create( + CrmContactEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmContactResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Contact object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, ContactsRetrieveRequest.builder().build()); + } + + /** + * Returns a Contact object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, ContactsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Contact object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Updates a Contact object with the given id. + */ + public MergeApiHttpResponse partialUpdate(String id, PatchedCrmContactEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates a Contact object with the given id. + */ + public MergeApiHttpResponse partialUpdate( + String id, PatchedCrmContactEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmContactResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public MergeApiHttpResponse ignoreCreate(String modelId, IgnoreCommonModelRequest request) { + return ignoreCreate(modelId, request, null); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public MergeApiHttpResponse ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts/ignore") + .addPathSegment(modelId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for CRMContact PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for CRMContact PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for CRMContact POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for CRMContact POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + ContactsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/contacts/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/contacts/requests/ContactsListRequest.java b/src/main/java/com/merge/api/resources/crm/contacts/requests/ContactsListRequest.java index adb2099b0..3849c07ca 100644 --- a/src/main/java/com/merge/api/resources/crm/contacts/requests/ContactsListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/contacts/requests/ContactsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.contacts.types.ContactsListRequestExpand; +import com.merge.api.resources.crm.contacts.types.ContactsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContactsListRequest.Builder.class) public final class ContactsListRequest { + private final Optional> expand; + private final Optional accountId; private final Optional createdAfter; @@ -32,8 +36,6 @@ public final class ContactsListRequest { private final Optional emailAddresses; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -55,12 +57,12 @@ public final class ContactsListRequest { private final Map additionalProperties; private ContactsListRequest( + Optional> expand, Optional accountId, Optional createdAfter, Optional createdBefore, Optional cursor, Optional emailAddresses, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -71,12 +73,12 @@ private ContactsListRequest( Optional phoneNumbers, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.accountId = accountId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.emailAddresses = emailAddresses; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -89,6 +91,14 @@ private ContactsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return contacts with this account. */ @@ -129,14 +139,6 @@ public Optional getEmailAddresses() { return emailAddresses; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -221,12 +223,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ContactsListRequest other) { - return accountId.equals(other.accountId) + return expand.equals(other.expand) + && accountId.equals(other.accountId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && emailAddresses.equals(other.emailAddresses) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -241,12 +243,12 @@ private boolean equalTo(ContactsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.accountId, this.createdAfter, this.createdBefore, this.cursor, this.emailAddresses, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -269,6 +271,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional accountId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -279,8 +283,6 @@ public static final class Builder { private Optional emailAddresses = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -305,12 +307,12 @@ public static final class Builder { private Builder() {} public Builder from(ContactsListRequest other) { + expand(other.getExpand()); accountId(other.getAccountId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); emailAddresses(other.getEmailAddresses()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -323,6 +325,22 @@ public Builder from(ContactsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(ContactsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "account_id", nulls = Nulls.SKIP) public Builder accountId(Optional accountId) { this.accountId = accountId; @@ -378,17 +396,6 @@ public Builder emailAddresses(String emailAddresses) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(ContactsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -490,12 +497,12 @@ public Builder remoteId(String remoteId) { public ContactsListRequest build() { return new ContactsListRequest( + expand, accountId, createdAfter, createdBefore, cursor, emailAddresses, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/crm/contacts/requests/ContactsRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/contacts/requests/ContactsRetrieveRequest.java index 420058c7f..68e0acb24 100644 --- a/src/main/java/com/merge/api/resources/crm/contacts/requests/ContactsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/contacts/requests/ContactsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.contacts.types.ContactsRetrieveRequestExpand; +import com.merge.api.resources.crm.contacts.types.ContactsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,22 +23,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContactsRetrieveRequest.Builder.class) public final class ContactsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private ContactsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -44,7 +50,7 @@ private ContactsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -64,6 +70,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -78,12 +92,13 @@ public Map getAdditionalProperties() { private boolean equalTo(ContactsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -97,12 +112,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -112,20 +129,26 @@ public Builder from(ContactsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(ContactsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(ContactsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -148,8 +171,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public ContactsRetrieveRequest build() { - return new ContactsRetrieveRequest(expand, includeRemoteData, includeRemoteFields, additionalProperties); + return new ContactsRetrieveRequest( + expand, includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsListRequestExpand.java b/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsListRequestExpand.java deleted file mode 100644 index 610e19be7..000000000 --- a/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.contacts.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ContactsListRequestExpand { - ACCOUNT("account"), - - ACCOUNT_OWNER("account,owner"), - - OWNER("owner"); - - private final String value; - - ContactsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsListRequestExpandItem.java new file mode 100644 index 000000000..4cea06b00 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.contacts.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ContactsListRequestExpandItem { + ACCOUNT("account"), + + OWNER("owner"); + + private final String value; + + ContactsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsRetrieveRequestExpand.java deleted file mode 100644 index ceecee706..000000000 --- a/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsRetrieveRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.contacts.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ContactsRetrieveRequestExpand { - ACCOUNT("account"), - - ACCOUNT_OWNER("account,owner"), - - OWNER("owner"); - - private final String value; - - ContactsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..1936dcb42 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/contacts/types/ContactsRetrieveRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.contacts.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ContactsRetrieveRequestExpandItem { + ACCOUNT("account"), + + OWNER("owner"); + + private final String value; + + ContactsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/customobjectclasses/AsyncCustomObjectClassesClient.java b/src/main/java/com/merge/api/resources/crm/customobjectclasses/AsyncCustomObjectClassesClient.java new file mode 100644 index 000000000..7da651236 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/customobjectclasses/AsyncCustomObjectClassesClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.customobjectclasses; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.customobjectclasses.requests.CustomObjectClassesListRequest; +import com.merge.api.resources.crm.customobjectclasses.requests.CustomObjectClassesRetrieveRequest; +import com.merge.api.resources.crm.types.CustomObjectClass; +import com.merge.api.resources.crm.types.PaginatedCustomObjectClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCustomObjectClassesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCustomObjectClassesClient rawClient; + + public AsyncCustomObjectClassesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCustomObjectClassesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCustomObjectClassesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of CustomObjectClass objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of CustomObjectClass objects. + */ + public CompletableFuture list(CustomObjectClassesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of CustomObjectClass objects. + */ + public CompletableFuture list( + CustomObjectClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a CustomObjectClass object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a CustomObjectClass object with the given id. + */ + public CompletableFuture retrieve(String id, CustomObjectClassesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a CustomObjectClass object with the given id. + */ + public CompletableFuture retrieve( + String id, CustomObjectClassesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/customobjectclasses/AsyncRawCustomObjectClassesClient.java b/src/main/java/com/merge/api/resources/crm/customobjectclasses/AsyncRawCustomObjectClassesClient.java new file mode 100644 index 000000000..5e647e668 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/customobjectclasses/AsyncRawCustomObjectClassesClient.java @@ -0,0 +1,241 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.customobjectclasses; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.customobjectclasses.requests.CustomObjectClassesListRequest; +import com.merge.api.resources.crm.customobjectclasses.requests.CustomObjectClassesRetrieveRequest; +import com.merge.api.resources.crm.types.CustomObjectClass; +import com.merge.api.resources.crm.types.PaginatedCustomObjectClassList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCustomObjectClassesClient { + protected final ClientOptions clientOptions; + + public AsyncRawCustomObjectClassesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of CustomObjectClass objects. + */ + public CompletableFuture> list() { + return list(CustomObjectClassesListRequest.builder().build()); + } + + /** + * Returns a list of CustomObjectClass objects. + */ + public CompletableFuture> list( + CustomObjectClassesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of CustomObjectClass objects. + */ + public CompletableFuture> list( + CustomObjectClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedCustomObjectClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a CustomObjectClass object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, CustomObjectClassesRetrieveRequest.builder().build()); + } + + /** + * Returns a CustomObjectClass object with the given id. + */ + public CompletableFuture> retrieve( + String id, CustomObjectClassesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a CustomObjectClass object with the given id. + */ + public CompletableFuture> retrieve( + String id, CustomObjectClassesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CustomObjectClass.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/customobjectclasses/CustomObjectClassesClient.java b/src/main/java/com/merge/api/resources/crm/customobjectclasses/CustomObjectClassesClient.java index 3984e41c6..0ff30a44e 100644 --- a/src/main/java/com/merge/api/resources/crm/customobjectclasses/CustomObjectClassesClient.java +++ b/src/main/java/com/merge/api/resources/crm/customobjectclasses/CustomObjectClassesClient.java @@ -3,130 +3,63 @@ */ package com.merge.api.resources.crm.customobjectclasses; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.customobjectclasses.requests.CustomObjectClassesListRequest; import com.merge.api.resources.crm.customobjectclasses.requests.CustomObjectClassesRetrieveRequest; import com.merge.api.resources.crm.types.CustomObjectClass; import com.merge.api.resources.crm.types.PaginatedCustomObjectClassList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class CustomObjectClassesClient { protected final ClientOptions clientOptions; + private final RawCustomObjectClassesClient rawClient; + public CustomObjectClassesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCustomObjectClassesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCustomObjectClassesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of CustomObjectClass objects. */ public PaginatedCustomObjectClassList list() { - return list(CustomObjectClassesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of CustomObjectClass objects. */ public PaginatedCustomObjectClassList list(CustomObjectClassesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of CustomObjectClass objects. */ public PaginatedCustomObjectClassList list(CustomObjectClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCustomObjectClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a CustomObjectClass object with the given id. */ public CustomObjectClass retrieve(String id) { - return retrieve(id, CustomObjectClassesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a CustomObjectClass object with the given id. */ public CustomObjectClass retrieve(String id, CustomObjectClassesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** @@ -134,40 +67,6 @@ public CustomObjectClass retrieve(String id, CustomObjectClassesRetrieveRequest */ public CustomObjectClass retrieve( String id, CustomObjectClassesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CustomObjectClass.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/customobjectclasses/RawCustomObjectClassesClient.java b/src/main/java/com/merge/api/resources/crm/customobjectclasses/RawCustomObjectClassesClient.java new file mode 100644 index 000000000..454061645 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/customobjectclasses/RawCustomObjectClassesClient.java @@ -0,0 +1,208 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.customobjectclasses; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.customobjectclasses.requests.CustomObjectClassesListRequest; +import com.merge.api.resources.crm.customobjectclasses.requests.CustomObjectClassesRetrieveRequest; +import com.merge.api.resources.crm.types.CustomObjectClass; +import com.merge.api.resources.crm.types.PaginatedCustomObjectClassList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCustomObjectClassesClient { + protected final ClientOptions clientOptions; + + public RawCustomObjectClassesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of CustomObjectClass objects. + */ + public MergeApiHttpResponse list() { + return list(CustomObjectClassesListRequest.builder().build()); + } + + /** + * Returns a list of CustomObjectClass objects. + */ + public MergeApiHttpResponse list(CustomObjectClassesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of CustomObjectClass objects. + */ + public MergeApiHttpResponse list( + CustomObjectClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedCustomObjectClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a CustomObjectClass object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, CustomObjectClassesRetrieveRequest.builder().build()); + } + + /** + * Returns a CustomObjectClass object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, CustomObjectClassesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a CustomObjectClass object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, CustomObjectClassesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CustomObjectClass.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/customobjectclasses/requests/CustomObjectClassesListRequest.java b/src/main/java/com/merge/api/resources/crm/customobjectclasses/requests/CustomObjectClassesListRequest.java index 145158f72..5adb3af5d 100644 --- a/src/main/java/com/merge/api/resources/crm/customobjectclasses/requests/CustomObjectClassesListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/customobjectclasses/requests/CustomObjectClassesListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,14 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CustomObjectClassesListRequest.Builder.class) public final class CustomObjectClassesListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -46,10 +48,10 @@ public final class CustomObjectClassesListRequest { private final Map additionalProperties; private CustomObjectClassesListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -58,10 +60,10 @@ private CustomObjectClassesListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -72,6 +74,14 @@ private CustomObjectClassesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -96,14 +106,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -172,10 +174,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(CustomObjectClassesListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -188,10 +190,10 @@ private boolean equalTo(CustomObjectClassesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -212,14 +214,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -240,10 +242,10 @@ public static final class Builder { private Builder() {} public Builder from(CustomObjectClassesListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -254,6 +256,22 @@ public Builder from(CustomObjectClassesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -287,17 +305,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -377,10 +384,10 @@ public Builder remoteId(String remoteId) { public CustomObjectClassesListRequest build() { return new CustomObjectClassesListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/crm/customobjectclasses/requests/CustomObjectClassesRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/customobjectclasses/requests/CustomObjectClassesRetrieveRequest.java index 1a029bafd..078747921 100644 --- a/src/main/java/com/merge/api/resources/crm/customobjectclasses/requests/CustomObjectClassesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/customobjectclasses/requests/CustomObjectClassesRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CustomObjectClassesRetrieveRequest.Builder.class) public final class CustomObjectClassesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private CustomObjectClassesRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private CustomObjectClassesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -62,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(CustomObjectClassesRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -81,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -93,20 +113,26 @@ private Builder() {} public Builder from(CustomObjectClassesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -118,8 +144,20 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public CustomObjectClassesRetrieveRequest build() { - return new CustomObjectClassesRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new CustomObjectClassesRetrieveRequest( + expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/customobjects/AsyncCustomObjectsClient.java b/src/main/java/com/merge/api/resources/crm/customobjects/AsyncCustomObjectsClient.java new file mode 100644 index 000000000..e0e320818 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/customobjects/AsyncCustomObjectsClient.java @@ -0,0 +1,169 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.customobjects; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.customobjects.requests.CrmCustomObjectEndpointRequest; +import com.merge.api.resources.crm.customobjects.requests.CustomObjectClassesCustomObjectsListRequest; +import com.merge.api.resources.crm.customobjects.requests.CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.customobjects.requests.CustomObjectClassesCustomObjectsRetrieveRequest; +import com.merge.api.resources.crm.types.CrmCustomObjectResponse; +import com.merge.api.resources.crm.types.CustomObject; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedCustomObjectList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCustomObjectsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCustomObjectsClient rawClient; + + public AsyncCustomObjectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCustomObjectsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCustomObjectsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of CustomObject objects. + */ + public CompletableFuture customObjectClassesCustomObjectsList( + String customObjectClassId) { + return this.rawClient + .customObjectClassesCustomObjectsList(customObjectClassId) + .thenApply(response -> response.body()); + } + + /** + * Returns a list of CustomObject objects. + */ + public CompletableFuture customObjectClassesCustomObjectsList( + String customObjectClassId, CustomObjectClassesCustomObjectsListRequest request) { + return this.rawClient + .customObjectClassesCustomObjectsList(customObjectClassId, request) + .thenApply(response -> response.body()); + } + + /** + * Returns a list of CustomObject objects. + */ + public CompletableFuture customObjectClassesCustomObjectsList( + String customObjectClassId, + CustomObjectClassesCustomObjectsListRequest request, + RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesCustomObjectsList(customObjectClassId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Creates a CustomObject object with the given values. + */ + public CompletableFuture customObjectClassesCustomObjectsCreate( + String customObjectClassId, CrmCustomObjectEndpointRequest request) { + return this.rawClient + .customObjectClassesCustomObjectsCreate(customObjectClassId, request) + .thenApply(response -> response.body()); + } + + /** + * Creates a CustomObject object with the given values. + */ + public CompletableFuture customObjectClassesCustomObjectsCreate( + String customObjectClassId, CrmCustomObjectEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesCustomObjectsCreate(customObjectClassId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns a CustomObject object with the given id. + */ + public CompletableFuture customObjectClassesCustomObjectsRetrieve( + String customObjectClassId, String id) { + return this.rawClient + .customObjectClassesCustomObjectsRetrieve(customObjectClassId, id) + .thenApply(response -> response.body()); + } + + /** + * Returns a CustomObject object with the given id. + */ + public CompletableFuture customObjectClassesCustomObjectsRetrieve( + String customObjectClassId, String id, CustomObjectClassesCustomObjectsRetrieveRequest request) { + return this.rawClient + .customObjectClassesCustomObjectsRetrieve(customObjectClassId, id, request) + .thenApply(response -> response.body()); + } + + /** + * Returns a CustomObject object with the given id. + */ + public CompletableFuture customObjectClassesCustomObjectsRetrieve( + String customObjectClassId, + String id, + CustomObjectClassesCustomObjectsRetrieveRequest request, + RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesCustomObjectsRetrieve(customObjectClassId, id, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMCustomObject POSTs. + */ + public CompletableFuture customObjectClassesCustomObjectsMetaPostRetrieve( + String customObjectClassId) { + return this.rawClient + .customObjectClassesCustomObjectsMetaPostRetrieve(customObjectClassId) + .thenApply(response -> response.body()); + } + + /** + * Returns metadata for CRMCustomObject POSTs. + */ + public CompletableFuture customObjectClassesCustomObjectsMetaPostRetrieve( + String customObjectClassId, RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesCustomObjectsMetaPostRetrieve(customObjectClassId, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture customObjectClassesCustomObjectsRemoteFieldClassesList() { + return this.rawClient + .customObjectClassesCustomObjectsRemoteFieldClassesList() + .thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture customObjectClassesCustomObjectsRemoteFieldClassesList( + CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest request) { + return this.rawClient + .customObjectClassesCustomObjectsRemoteFieldClassesList(request) + .thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture customObjectClassesCustomObjectsRemoteFieldClassesList( + CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient + .customObjectClassesCustomObjectsRemoteFieldClassesList(request, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/customobjects/AsyncRawCustomObjectsClient.java b/src/main/java/com/merge/api/resources/crm/customobjects/AsyncRawCustomObjectsClient.java new file mode 100644 index 000000000..572c487b1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/customobjects/AsyncRawCustomObjectsClient.java @@ -0,0 +1,526 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.customobjects; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.customobjects.requests.CrmCustomObjectEndpointRequest; +import com.merge.api.resources.crm.customobjects.requests.CustomObjectClassesCustomObjectsListRequest; +import com.merge.api.resources.crm.customobjects.requests.CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.customobjects.requests.CustomObjectClassesCustomObjectsRetrieveRequest; +import com.merge.api.resources.crm.types.CrmCustomObjectResponse; +import com.merge.api.resources.crm.types.CustomObject; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedCustomObjectList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCustomObjectsClient { + protected final ClientOptions clientOptions; + + public AsyncRawCustomObjectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of CustomObject objects. + */ + public CompletableFuture> customObjectClassesCustomObjectsList( + String customObjectClassId) { + return customObjectClassesCustomObjectsList( + customObjectClassId, + CustomObjectClassesCustomObjectsListRequest.builder().build()); + } + + /** + * Returns a list of CustomObject objects. + */ + public CompletableFuture> customObjectClassesCustomObjectsList( + String customObjectClassId, CustomObjectClassesCustomObjectsListRequest request) { + return customObjectClassesCustomObjectsList(customObjectClassId, request, null); + } + + /** + * Returns a list of CustomObject objects. + */ + public CompletableFuture> customObjectClassesCustomObjectsList( + String customObjectClassId, + CustomObjectClassesCustomObjectsListRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("custom-objects"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedCustomObjectList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a CustomObject object with the given values. + */ + public CompletableFuture> customObjectClassesCustomObjectsCreate( + String customObjectClassId, CrmCustomObjectEndpointRequest request) { + return customObjectClassesCustomObjectsCreate(customObjectClassId, request, null); + } + + /** + * Creates a CustomObject object with the given values. + */ + public CompletableFuture> customObjectClassesCustomObjectsCreate( + String customObjectClassId, CrmCustomObjectEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("custom-objects"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), CrmCustomObjectResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a CustomObject object with the given id. + */ + public CompletableFuture> customObjectClassesCustomObjectsRetrieve( + String customObjectClassId, String id) { + return customObjectClassesCustomObjectsRetrieve( + customObjectClassId, + id, + CustomObjectClassesCustomObjectsRetrieveRequest.builder().build()); + } + + /** + * Returns a CustomObject object with the given id. + */ + public CompletableFuture> customObjectClassesCustomObjectsRetrieve( + String customObjectClassId, String id, CustomObjectClassesCustomObjectsRetrieveRequest request) { + return customObjectClassesCustomObjectsRetrieve(customObjectClassId, id, request, null); + } + + /** + * Returns a CustomObject object with the given id. + */ + public CompletableFuture> customObjectClassesCustomObjectsRetrieve( + String customObjectClassId, + String id, + CustomObjectClassesCustomObjectsRetrieveRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("custom-objects") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CustomObject.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for CRMCustomObject POSTs. + */ + public CompletableFuture> customObjectClassesCustomObjectsMetaPostRetrieve( + String customObjectClassId) { + return customObjectClassesCustomObjectsMetaPostRetrieve(customObjectClassId, null); + } + + /** + * Returns metadata for CRMCustomObject POSTs. + */ + public CompletableFuture> customObjectClassesCustomObjectsMetaPostRetrieve( + String customObjectClassId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("custom-objects/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> + customObjectClassesCustomObjectsRemoteFieldClassesList() { + return customObjectClassesCustomObjectsRemoteFieldClassesList( + CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest.builder() + .build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> + customObjectClassesCustomObjectsRemoteFieldClassesList( + CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest request) { + return customObjectClassesCustomObjectsRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> + customObjectClassesCustomObjectsRemoteFieldClassesList( + CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes/custom-objects/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/customobjects/CustomObjectsClient.java b/src/main/java/com/merge/api/resources/crm/customobjects/CustomObjectsClient.java index 5905653a2..30b50997a 100644 --- a/src/main/java/com/merge/api/resources/crm/customobjects/CustomObjectsClient.java +++ b/src/main/java/com/merge/api/resources/crm/customobjects/CustomObjectsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.crm.customobjects; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.customobjects.requests.CrmCustomObjectEndpointRequest; import com.merge.api.resources.crm.customobjects.requests.CustomObjectClassesCustomObjectsListRequest; @@ -18,31 +14,31 @@ import com.merge.api.resources.crm.types.MetaResponse; import com.merge.api.resources.crm.types.PaginatedCustomObjectList; import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class CustomObjectsClient { protected final ClientOptions clientOptions; + private final RawCustomObjectsClient rawClient; + public CustomObjectsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCustomObjectsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCustomObjectsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of CustomObject objects. */ public PaginatedCustomObjectList customObjectClassesCustomObjectsList(String customObjectClassId) { - return customObjectClassesCustomObjectsList( - customObjectClassId, - CustomObjectClassesCustomObjectsListRequest.builder().build()); + return this.rawClient + .customObjectClassesCustomObjectsList(customObjectClassId) + .body(); } /** @@ -50,7 +46,9 @@ public PaginatedCustomObjectList customObjectClassesCustomObjectsList(String cus */ public PaginatedCustomObjectList customObjectClassesCustomObjectsList( String customObjectClassId, CustomObjectClassesCustomObjectsListRequest request) { - return customObjectClassesCustomObjectsList(customObjectClassId, request, null); + return this.rawClient + .customObjectClassesCustomObjectsList(customObjectClassId, request) + .body(); } /** @@ -60,78 +58,9 @@ public PaginatedCustomObjectList customObjectClassesCustomObjectsList( String customObjectClassId, CustomObjectClassesCustomObjectsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(customObjectClassId) - .addPathSegments("custom-objects"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCustomObjectList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesCustomObjectsList(customObjectClassId, request, requestOptions) + .body(); } /** @@ -139,7 +68,9 @@ public PaginatedCustomObjectList customObjectClassesCustomObjectsList( */ public CrmCustomObjectResponse customObjectClassesCustomObjectsCreate( String customObjectClassId, CrmCustomObjectEndpointRequest request) { - return customObjectClassesCustomObjectsCreate(customObjectClassId, request, null); + return this.rawClient + .customObjectClassesCustomObjectsCreate(customObjectClassId, request) + .body(); } /** @@ -147,61 +78,18 @@ public CrmCustomObjectResponse customObjectClassesCustomObjectsCreate( */ public CrmCustomObjectResponse customObjectClassesCustomObjectsCreate( String customObjectClassId, CrmCustomObjectEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(customObjectClassId) - .addPathSegments("custom-objects"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmCustomObjectResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesCustomObjectsCreate(customObjectClassId, request, requestOptions) + .body(); } /** * Returns a CustomObject object with the given id. */ public CustomObject customObjectClassesCustomObjectsRetrieve(String customObjectClassId, String id) { - return customObjectClassesCustomObjectsRetrieve( - customObjectClassId, - id, - CustomObjectClassesCustomObjectsRetrieveRequest.builder().build()); + return this.rawClient + .customObjectClassesCustomObjectsRetrieve(customObjectClassId, id) + .body(); } /** @@ -209,7 +97,9 @@ public CustomObject customObjectClassesCustomObjectsRetrieve(String customObject */ public CustomObject customObjectClassesCustomObjectsRetrieve( String customObjectClassId, String id, CustomObjectClassesCustomObjectsRetrieveRequest request) { - return customObjectClassesCustomObjectsRetrieve(customObjectClassId, id, request, null); + return this.rawClient + .customObjectClassesCustomObjectsRetrieve(customObjectClassId, id, request) + .body(); } /** @@ -220,52 +110,18 @@ public CustomObject customObjectClassesCustomObjectsRetrieve( String id, CustomObjectClassesCustomObjectsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(customObjectClassId) - .addPathSegments("custom-objects") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CustomObject.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesCustomObjectsRetrieve(customObjectClassId, id, request, requestOptions) + .body(); } /** * Returns metadata for CRMCustomObject POSTs. */ public MetaResponse customObjectClassesCustomObjectsMetaPostRetrieve(String customObjectClassId) { - return customObjectClassesCustomObjectsMetaPostRetrieve(customObjectClassId, null); + return this.rawClient + .customObjectClassesCustomObjectsMetaPostRetrieve(customObjectClassId) + .body(); } /** @@ -273,45 +129,18 @@ public MetaResponse customObjectClassesCustomObjectsMetaPostRetrieve(String cust */ public MetaResponse customObjectClassesCustomObjectsMetaPostRetrieve( String customObjectClassId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes") - .addPathSegment(customObjectClassId) - .addPathSegments("custom-objects/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesCustomObjectsMetaPostRetrieve(customObjectClassId, requestOptions) + .body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList customObjectClassesCustomObjectsRemoteFieldClassesList() { - return customObjectClassesCustomObjectsRemoteFieldClassesList( - CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest.builder() - .build()); + return this.rawClient + .customObjectClassesCustomObjectsRemoteFieldClassesList() + .body(); } /** @@ -319,7 +148,9 @@ public PaginatedRemoteFieldClassList customObjectClassesCustomObjectsRemoteField */ public PaginatedRemoteFieldClassList customObjectClassesCustomObjectsRemoteFieldClassesList( CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest request) { - return customObjectClassesCustomObjectsRemoteFieldClassesList(request, null); + return this.rawClient + .customObjectClassesCustomObjectsRemoteFieldClassesList(request) + .body(); } /** @@ -327,61 +158,8 @@ public PaginatedRemoteFieldClassList customObjectClassesCustomObjectsRemoteField */ public PaginatedRemoteFieldClassList customObjectClassesCustomObjectsRemoteFieldClassesList( CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/custom-object-classes/custom-objects/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .customObjectClassesCustomObjectsRemoteFieldClassesList(request, requestOptions) + .body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/customobjects/RawCustomObjectsClient.java b/src/main/java/com/merge/api/resources/crm/customobjects/RawCustomObjectsClient.java new file mode 100644 index 000000000..682777cb9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/customobjects/RawCustomObjectsClient.java @@ -0,0 +1,449 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.customobjects; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.customobjects.requests.CrmCustomObjectEndpointRequest; +import com.merge.api.resources.crm.customobjects.requests.CustomObjectClassesCustomObjectsListRequest; +import com.merge.api.resources.crm.customobjects.requests.CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.customobjects.requests.CustomObjectClassesCustomObjectsRetrieveRequest; +import com.merge.api.resources.crm.types.CrmCustomObjectResponse; +import com.merge.api.resources.crm.types.CustomObject; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedCustomObjectList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCustomObjectsClient { + protected final ClientOptions clientOptions; + + public RawCustomObjectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of CustomObject objects. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsList( + String customObjectClassId) { + return customObjectClassesCustomObjectsList( + customObjectClassId, + CustomObjectClassesCustomObjectsListRequest.builder().build()); + } + + /** + * Returns a list of CustomObject objects. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsList( + String customObjectClassId, CustomObjectClassesCustomObjectsListRequest request) { + return customObjectClassesCustomObjectsList(customObjectClassId, request, null); + } + + /** + * Returns a list of CustomObject objects. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsList( + String customObjectClassId, + CustomObjectClassesCustomObjectsListRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("custom-objects"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCustomObjectList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a CustomObject object with the given values. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsCreate( + String customObjectClassId, CrmCustomObjectEndpointRequest request) { + return customObjectClassesCustomObjectsCreate(customObjectClassId, request, null); + } + + /** + * Creates a CustomObject object with the given values. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsCreate( + String customObjectClassId, CrmCustomObjectEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("custom-objects"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CrmCustomObjectResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a CustomObject object with the given id. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsRetrieve( + String customObjectClassId, String id) { + return customObjectClassesCustomObjectsRetrieve( + customObjectClassId, + id, + CustomObjectClassesCustomObjectsRetrieveRequest.builder().build()); + } + + /** + * Returns a CustomObject object with the given id. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsRetrieve( + String customObjectClassId, String id, CustomObjectClassesCustomObjectsRetrieveRequest request) { + return customObjectClassesCustomObjectsRetrieve(customObjectClassId, id, request, null); + } + + /** + * Returns a CustomObject object with the given id. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsRetrieve( + String customObjectClassId, + String id, + CustomObjectClassesCustomObjectsRetrieveRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("custom-objects") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CustomObject.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for CRMCustomObject POSTs. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsMetaPostRetrieve( + String customObjectClassId) { + return customObjectClassesCustomObjectsMetaPostRetrieve(customObjectClassId, null); + } + + /** + * Returns metadata for CRMCustomObject POSTs. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsMetaPostRetrieve( + String customObjectClassId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes") + .addPathSegment(customObjectClassId) + .addPathSegments("custom-objects/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse + customObjectClassesCustomObjectsRemoteFieldClassesList() { + return customObjectClassesCustomObjectsRemoteFieldClassesList( + CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest.builder() + .build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsRemoteFieldClassesList( + CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest request) { + return customObjectClassesCustomObjectsRemoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse customObjectClassesCustomObjectsRemoteFieldClassesList( + CustomObjectClassesCustomObjectsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/custom-object-classes/custom-objects/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/customobjects/requests/CustomObjectClassesCustomObjectsRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/customobjects/requests/CustomObjectClassesCustomObjectsRetrieveRequest.java index 8578c2a2f..2bd4aa6fd 100644 --- a/src/main/java/com/merge/api/resources/crm/customobjects/requests/CustomObjectClassesCustomObjectsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/customobjects/requests/CustomObjectClassesCustomObjectsRetrieveRequest.java @@ -24,14 +24,18 @@ public final class CustomObjectClassesCustomObjectsRetrieveRequest { private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private CustomObjectClassesCustomObjectsRetrieveRequest( Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -51,6 +55,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -65,12 +77,13 @@ public Map getAdditionalProperties() { private boolean equalTo(CustomObjectClassesCustomObjectsRetrieveRequest other) { return includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -88,6 +101,8 @@ public static final class Builder { private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -96,6 +111,7 @@ private Builder() {} public Builder from(CustomObjectClassesCustomObjectsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @@ -121,9 +137,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public CustomObjectClassesCustomObjectsRetrieveRequest build() { return new CustomObjectClassesCustomObjectsRetrieveRequest( - includeRemoteData, includeRemoteFields, additionalProperties); + includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/deleteaccount/AsyncDeleteAccountClient.java b/src/main/java/com/merge/api/resources/crm/deleteaccount/AsyncDeleteAccountClient.java new file mode 100644 index 000000000..5831fe068 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/deleteaccount/AsyncDeleteAccountClient.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.deleteaccount; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import java.util.concurrent.CompletableFuture; + +public class AsyncDeleteAccountClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDeleteAccountClient rawClient; + + public AsyncDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDeleteAccountClient withRawResponse() { + return this.rawClient; + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete() { + return this.rawClient.delete().thenApply(response -> response.body()); + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete(RequestOptions requestOptions) { + return this.rawClient.delete(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/deleteaccount/AsyncRawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/crm/deleteaccount/AsyncRawDeleteAccountClient.java new file mode 100644 index 000000000..d9528bf2a --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/deleteaccount/AsyncRawDeleteAccountClient.java @@ -0,0 +1,84 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public AsyncRawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/deleteaccount/DeleteAccountClient.java b/src/main/java/com/merge/api/resources/crm/deleteaccount/DeleteAccountClient.java index 4742cea8a..e558ef1d6 100644 --- a/src/main/java/com/merge/api/resources/crm/deleteaccount/DeleteAccountClient.java +++ b/src/main/java/com/merge/api/resources/crm/deleteaccount/DeleteAccountClient.java @@ -3,63 +3,37 @@ */ package com.merge.api.resources.crm.deleteaccount; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class DeleteAccountClient { protected final ClientOptions clientOptions; + private final RawDeleteAccountClient rawClient; + public DeleteAccountClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDeleteAccountClient withRawResponse() { + return this.rawClient; } /** * Delete a linked account. */ public void delete() { - delete(null); + this.rawClient.delete().body(); } /** * Delete a linked account. */ public void delete(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/delete-account") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + this.rawClient.delete(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/deleteaccount/RawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/crm/deleteaccount/RawDeleteAccountClient.java new file mode 100644 index 000000000..e01ca0756 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/deleteaccount/RawDeleteAccountClient.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public RawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/engagements/AsyncEngagementsClient.java b/src/main/java/com/merge/api/resources/crm/engagements/AsyncEngagementsClient.java new file mode 100644 index 000000000..6f9283811 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/engagements/AsyncEngagementsClient.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.engagements; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.engagements.requests.EngagementEndpointRequest; +import com.merge.api.resources.crm.engagements.requests.EngagementsListRequest; +import com.merge.api.resources.crm.engagements.requests.EngagementsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.engagements.requests.EngagementsRetrieveRequest; +import com.merge.api.resources.crm.engagements.requests.PatchedEngagementEndpointRequest; +import com.merge.api.resources.crm.types.Engagement; +import com.merge.api.resources.crm.types.EngagementResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedEngagementList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncEngagementsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawEngagementsClient rawClient; + + public AsyncEngagementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawEngagementsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawEngagementsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Engagement objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Engagement objects. + */ + public CompletableFuture list(EngagementsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Engagement objects. + */ + public CompletableFuture list( + EngagementsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Engagement object with the given values. + */ + public CompletableFuture create(EngagementEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Engagement object with the given values. + */ + public CompletableFuture create( + EngagementEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Engagement object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Engagement object with the given id. + */ + public CompletableFuture retrieve(String id, EngagementsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Engagement object with the given id. + */ + public CompletableFuture retrieve( + String id, EngagementsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates an Engagement object with the given id. + */ + public CompletableFuture partialUpdate(String id, PatchedEngagementEndpointRequest request) { + return this.rawClient.partialUpdate(id, request).thenApply(response -> response.body()); + } + + /** + * Updates an Engagement object with the given id. + */ + public CompletableFuture partialUpdate( + String id, PatchedEngagementEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.partialUpdate(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Engagement PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id) { + return this.rawClient.metaPatchRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Engagement PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id, RequestOptions requestOptions) { + return this.rawClient.metaPatchRetrieve(id, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Engagement POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Engagement POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + EngagementsRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + EngagementsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/engagements/AsyncRawEngagementsClient.java b/src/main/java/com/merge/api/resources/crm/engagements/AsyncRawEngagementsClient.java new file mode 100644 index 000000000..a4f351aa1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/engagements/AsyncRawEngagementsClient.java @@ -0,0 +1,647 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.engagements; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.engagements.requests.EngagementEndpointRequest; +import com.merge.api.resources.crm.engagements.requests.EngagementsListRequest; +import com.merge.api.resources.crm.engagements.requests.EngagementsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.engagements.requests.EngagementsRetrieveRequest; +import com.merge.api.resources.crm.engagements.requests.PatchedEngagementEndpointRequest; +import com.merge.api.resources.crm.types.Engagement; +import com.merge.api.resources.crm.types.EngagementResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedEngagementList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawEngagementsClient { + protected final ClientOptions clientOptions; + + public AsyncRawEngagementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Engagement objects. + */ + public CompletableFuture> list() { + return list(EngagementsListRequest.builder().build()); + } + + /** + * Returns a list of Engagement objects. + */ + public CompletableFuture> list(EngagementsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Engagement objects. + */ + public CompletableFuture> list( + EngagementsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedEngagementList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Engagement object with the given values. + */ + public CompletableFuture> create(EngagementEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Engagement object with the given values. + */ + public CompletableFuture> create( + EngagementEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EngagementResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Engagement object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, EngagementsRetrieveRequest.builder().build()); + } + + /** + * Returns an Engagement object with the given id. + */ + public CompletableFuture> retrieve(String id, EngagementsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Engagement object with the given id. + */ + public CompletableFuture> retrieve( + String id, EngagementsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Engagement.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Updates an Engagement object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedEngagementEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates an Engagement object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedEngagementEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EngagementResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Engagement PATCHs. + */ + public CompletableFuture> metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Engagement PATCHs. + */ + public CompletableFuture> metaPatchRetrieve( + String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Engagement POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Engagement POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + EngagementsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + EngagementsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + EngagementsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/engagements/EngagementsClient.java b/src/main/java/com/merge/api/resources/crm/engagements/EngagementsClient.java index 90d90bc21..dbfcdc840 100644 --- a/src/main/java/com/merge/api/resources/crm/engagements/EngagementsClient.java +++ b/src/main/java/com/merge/api/resources/crm/engagements/EngagementsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.crm.engagements; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.engagements.requests.EngagementEndpointRequest; import com.merge.api.resources.crm.engagements.requests.EngagementsListRequest; @@ -19,246 +15,85 @@ import com.merge.api.resources.crm.types.MetaResponse; import com.merge.api.resources.crm.types.PaginatedEngagementList; import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class EngagementsClient { protected final ClientOptions clientOptions; + private final RawEngagementsClient rawClient; + public EngagementsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawEngagementsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawEngagementsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Engagement objects. */ public PaginatedEngagementList list() { - return list(EngagementsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Engagement objects. */ public PaginatedEngagementList list(EngagementsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Engagement objects. */ public PaginatedEngagementList list(EngagementsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/engagements"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getStartedAfter().isPresent()) { - httpUrl.addQueryParameter( - "started_after", request.getStartedAfter().get().toString()); - } - if (request.getStartedBefore().isPresent()) { - httpUrl.addQueryParameter( - "started_before", request.getStartedBefore().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEngagementList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates an Engagement object with the given values. */ public EngagementResponse create(EngagementEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates an Engagement object with the given values. */ public EngagementResponse create(EngagementEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/engagements"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EngagementResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Engagement object with the given id. */ public Engagement retrieve(String id) { - return retrieve(id, EngagementsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Engagement object with the given id. */ public Engagement retrieve(String id, EngagementsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Engagement object with the given id. */ public Engagement retrieve(String id, EngagementsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/engagements") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Engagement.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Updates an Engagement object with the given id. */ public EngagementResponse partialUpdate(String id, PatchedEngagementEndpointRequest request) { - return partialUpdate(id, request, null); + return this.rawClient.partialUpdate(id, request).body(); } /** @@ -266,148 +101,49 @@ public EngagementResponse partialUpdate(String id, PatchedEngagementEndpointRequ */ public EngagementResponse partialUpdate( String id, PatchedEngagementEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/engagements") - .addPathSegment(id); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EngagementResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.partialUpdate(id, request, requestOptions).body(); } /** * Returns metadata for Engagement PATCHs. */ public MetaResponse metaPatchRetrieve(String id) { - return metaPatchRetrieve(id, null); + return this.rawClient.metaPatchRetrieve(id).body(); } /** * Returns metadata for Engagement PATCHs. */ public MetaResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/engagements/meta/patch") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPatchRetrieve(id, requestOptions).body(); } /** * Returns metadata for Engagement POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Engagement POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/engagements/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - EngagementsRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(EngagementsRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -415,61 +151,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(EngagementsRemoteFie */ public PaginatedRemoteFieldClassList remoteFieldClassesList( EngagementsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/engagements/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/engagements/RawEngagementsClient.java b/src/main/java/com/merge/api/resources/crm/engagements/RawEngagementsClient.java new file mode 100644 index 000000000..868a6f65b --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/engagements/RawEngagementsClient.java @@ -0,0 +1,543 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.engagements; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.engagements.requests.EngagementEndpointRequest; +import com.merge.api.resources.crm.engagements.requests.EngagementsListRequest; +import com.merge.api.resources.crm.engagements.requests.EngagementsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.engagements.requests.EngagementsRetrieveRequest; +import com.merge.api.resources.crm.engagements.requests.PatchedEngagementEndpointRequest; +import com.merge.api.resources.crm.types.Engagement; +import com.merge.api.resources.crm.types.EngagementResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedEngagementList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawEngagementsClient { + protected final ClientOptions clientOptions; + + public RawEngagementsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Engagement objects. + */ + public MergeApiHttpResponse list() { + return list(EngagementsListRequest.builder().build()); + } + + /** + * Returns a list of Engagement objects. + */ + public MergeApiHttpResponse list(EngagementsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Engagement objects. + */ + public MergeApiHttpResponse list( + EngagementsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEngagementList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Engagement object with the given values. + */ + public MergeApiHttpResponse create(EngagementEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Engagement object with the given values. + */ + public MergeApiHttpResponse create( + EngagementEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EngagementResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Engagement object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, EngagementsRetrieveRequest.builder().build()); + } + + /** + * Returns an Engagement object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, EngagementsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Engagement object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, EngagementsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Engagement.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Updates an Engagement object with the given id. + */ + public MergeApiHttpResponse partialUpdate(String id, PatchedEngagementEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates an Engagement object with the given id. + */ + public MergeApiHttpResponse partialUpdate( + String id, PatchedEngagementEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EngagementResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Engagement PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Engagement PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Engagement POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Engagement POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + EngagementsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + EngagementsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + EngagementsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagements/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/engagements/requests/EngagementsListRequest.java b/src/main/java/com/merge/api/resources/crm/engagements/requests/EngagementsListRequest.java index 88b094dec..9431509f3 100644 --- a/src/main/java/com/merge/api/resources/crm/engagements/requests/EngagementsListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/engagements/requests/EngagementsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.engagements.types.EngagementsListRequestExpand; +import com.merge.api.resources.crm.engagements.types.EngagementsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,14 +24,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EngagementsListRequest.Builder.class) public final class EngagementsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -53,10 +55,10 @@ public final class EngagementsListRequest { private final Map additionalProperties; private EngagementsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -68,10 +70,10 @@ private EngagementsListRequest( Optional startedAfter, Optional startedBefore, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -85,6 +87,14 @@ private EngagementsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -109,14 +119,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -209,10 +211,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(EngagementsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -228,10 +230,10 @@ private boolean equalTo(EngagementsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -255,14 +257,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -289,10 +291,10 @@ public static final class Builder { private Builder() {} public Builder from(EngagementsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -306,6 +308,22 @@ public Builder from(EngagementsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(EngagementsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -339,17 +357,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(EngagementsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -462,10 +469,10 @@ public Builder startedBefore(OffsetDateTime startedBefore) { public EngagementsListRequest build() { return new EngagementsListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/crm/engagements/requests/EngagementsRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/engagements/requests/EngagementsRetrieveRequest.java index 8c10a3b9c..56631da2d 100644 --- a/src/main/java/com/merge/api/resources/crm/engagements/requests/EngagementsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/engagements/requests/EngagementsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.engagements.types.EngagementsRetrieveRequestExpand; +import com.merge.api.resources.crm.engagements.types.EngagementsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,22 +23,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EngagementsRetrieveRequest.Builder.class) public final class EngagementsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private EngagementsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -44,7 +50,7 @@ private EngagementsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -64,6 +70,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -78,12 +92,13 @@ public Map getAdditionalProperties() { private boolean equalTo(EngagementsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -97,12 +112,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -112,20 +129,26 @@ public Builder from(EngagementsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(EngagementsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(EngagementsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -148,8 +171,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public EngagementsRetrieveRequest build() { - return new EngagementsRetrieveRequest(expand, includeRemoteData, includeRemoteFields, additionalProperties); + return new EngagementsRetrieveRequest( + expand, includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsListRequestExpand.java b/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsListRequestExpand.java deleted file mode 100644 index 312834677..000000000 --- a/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsListRequestExpand.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.engagements.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum EngagementsListRequestExpand { - ACCOUNT("account"), - - ACCOUNT_ENGAGEMENT_TYPE("account,engagement_type"), - - CONTACTS("contacts"), - - CONTACTS_ACCOUNT("contacts,account"), - - CONTACTS_ACCOUNT_ENGAGEMENT_TYPE("contacts,account,engagement_type"), - - CONTACTS_ENGAGEMENT_TYPE("contacts,engagement_type"), - - CONTACTS_OWNER("contacts,owner"), - - CONTACTS_OWNER_ACCOUNT("contacts,owner,account"), - - CONTACTS_OWNER_ACCOUNT_ENGAGEMENT_TYPE("contacts,owner,account,engagement_type"), - - CONTACTS_OWNER_ENGAGEMENT_TYPE("contacts,owner,engagement_type"), - - ENGAGEMENT_TYPE("engagement_type"), - - OWNER("owner"), - - OWNER_ACCOUNT("owner,account"), - - OWNER_ACCOUNT_ENGAGEMENT_TYPE("owner,account,engagement_type"), - - OWNER_ENGAGEMENT_TYPE("owner,engagement_type"); - - private final String value; - - EngagementsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsListRequestExpandItem.java new file mode 100644 index 000000000..692b8e662 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsListRequestExpandItem.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.engagements.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EngagementsListRequestExpandItem { + ACCOUNT("account"), + + CONTACTS("contacts"), + + ENGAGEMENT_TYPE("engagement_type"), + + OWNER("owner"); + + private final String value; + + EngagementsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsRetrieveRequestExpand.java deleted file mode 100644 index 78f693e77..000000000 --- a/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsRetrieveRequestExpand.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.engagements.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum EngagementsRetrieveRequestExpand { - ACCOUNT("account"), - - ACCOUNT_ENGAGEMENT_TYPE("account,engagement_type"), - - CONTACTS("contacts"), - - CONTACTS_ACCOUNT("contacts,account"), - - CONTACTS_ACCOUNT_ENGAGEMENT_TYPE("contacts,account,engagement_type"), - - CONTACTS_ENGAGEMENT_TYPE("contacts,engagement_type"), - - CONTACTS_OWNER("contacts,owner"), - - CONTACTS_OWNER_ACCOUNT("contacts,owner,account"), - - CONTACTS_OWNER_ACCOUNT_ENGAGEMENT_TYPE("contacts,owner,account,engagement_type"), - - CONTACTS_OWNER_ENGAGEMENT_TYPE("contacts,owner,engagement_type"), - - ENGAGEMENT_TYPE("engagement_type"), - - OWNER("owner"), - - OWNER_ACCOUNT("owner,account"), - - OWNER_ACCOUNT_ENGAGEMENT_TYPE("owner,account,engagement_type"), - - OWNER_ENGAGEMENT_TYPE("owner,engagement_type"); - - private final String value; - - EngagementsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..21e21c349 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/engagements/types/EngagementsRetrieveRequestExpandItem.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.engagements.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EngagementsRetrieveRequestExpandItem { + ACCOUNT("account"), + + CONTACTS("contacts"), + + ENGAGEMENT_TYPE("engagement_type"), + + OWNER("owner"); + + private final String value; + + EngagementsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/engagementtypes/AsyncEngagementTypesClient.java b/src/main/java/com/merge/api/resources/crm/engagementtypes/AsyncEngagementTypesClient.java new file mode 100644 index 000000000..22d27daf0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/engagementtypes/AsyncEngagementTypesClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.engagementtypes; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesListRequest; +import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesRetrieveRequest; +import com.merge.api.resources.crm.types.EngagementType; +import com.merge.api.resources.crm.types.PaginatedEngagementTypeList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncEngagementTypesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawEngagementTypesClient rawClient; + + public AsyncEngagementTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawEngagementTypesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawEngagementTypesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of EngagementType objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of EngagementType objects. + */ + public CompletableFuture list(EngagementTypesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of EngagementType objects. + */ + public CompletableFuture list( + EngagementTypesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an EngagementType object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an EngagementType object with the given id. + */ + public CompletableFuture retrieve(String id, EngagementTypesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an EngagementType object with the given id. + */ + public CompletableFuture retrieve( + String id, EngagementTypesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + EngagementTypesRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + EngagementTypesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/engagementtypes/AsyncRawEngagementTypesClient.java b/src/main/java/com/merge/api/resources/crm/engagementtypes/AsyncRawEngagementTypesClient.java new file mode 100644 index 000000000..6e8096edd --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/engagementtypes/AsyncRawEngagementTypesClient.java @@ -0,0 +1,359 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.engagementtypes; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesListRequest; +import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesRetrieveRequest; +import com.merge.api.resources.crm.types.EngagementType; +import com.merge.api.resources.crm.types.PaginatedEngagementTypeList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawEngagementTypesClient { + protected final ClientOptions clientOptions; + + public AsyncRawEngagementTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of EngagementType objects. + */ + public CompletableFuture> list() { + return list(EngagementTypesListRequest.builder().build()); + } + + /** + * Returns a list of EngagementType objects. + */ + public CompletableFuture> list( + EngagementTypesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of EngagementType objects. + */ + public CompletableFuture> list( + EngagementTypesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagement-types"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedEngagementTypeList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an EngagementType object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, EngagementTypesRetrieveRequest.builder().build()); + } + + /** + * Returns an EngagementType object with the given id. + */ + public CompletableFuture> retrieve( + String id, EngagementTypesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an EngagementType object with the given id. + */ + public CompletableFuture> retrieve( + String id, EngagementTypesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagement-types") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EngagementType.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + EngagementTypesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + EngagementTypesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + EngagementTypesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagement-types/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/engagementtypes/EngagementTypesClient.java b/src/main/java/com/merge/api/resources/crm/engagementtypes/EngagementTypesClient.java index 2ac6c7e4b..9bf2157bc 100644 --- a/src/main/java/com/merge/api/resources/crm/engagementtypes/EngagementTypesClient.java +++ b/src/main/java/com/merge/api/resources/crm/engagementtypes/EngagementTypesClient.java @@ -3,10 +3,7 @@ */ package com.merge.api.resources.crm.engagementtypes; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesListRequest; import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesRemoteFieldClassesListRequest; @@ -14,181 +11,78 @@ import com.merge.api.resources.crm.types.EngagementType; import com.merge.api.resources.crm.types.PaginatedEngagementTypeList; import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class EngagementTypesClient { protected final ClientOptions clientOptions; + private final RawEngagementTypesClient rawClient; + public EngagementTypesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawEngagementTypesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawEngagementTypesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of EngagementType objects. */ public PaginatedEngagementTypeList list() { - return list(EngagementTypesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of EngagementType objects. */ public PaginatedEngagementTypeList list(EngagementTypesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of EngagementType objects. */ public PaginatedEngagementTypeList list(EngagementTypesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/engagement-types"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEngagementTypeList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an EngagementType object with the given id. */ public EngagementType retrieve(String id) { - return retrieve(id, EngagementTypesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an EngagementType object with the given id. */ public EngagementType retrieve(String id, EngagementTypesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an EngagementType object with the given id. */ public EngagementType retrieve(String id, EngagementTypesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/engagement-types") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EngagementType.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - EngagementTypesRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(EngagementTypesRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -196,61 +90,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(EngagementTypesRemot */ public PaginatedRemoteFieldClassList remoteFieldClassesList( EngagementTypesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/engagement-types/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/engagementtypes/RawEngagementTypesClient.java b/src/main/java/com/merge/api/resources/crm/engagementtypes/RawEngagementTypesClient.java new file mode 100644 index 000000000..dbf8fadb5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/engagementtypes/RawEngagementTypesClient.java @@ -0,0 +1,311 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.engagementtypes; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesListRequest; +import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.engagementtypes.requests.EngagementTypesRetrieveRequest; +import com.merge.api.resources.crm.types.EngagementType; +import com.merge.api.resources.crm.types.PaginatedEngagementTypeList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawEngagementTypesClient { + protected final ClientOptions clientOptions; + + public RawEngagementTypesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of EngagementType objects. + */ + public MergeApiHttpResponse list() { + return list(EngagementTypesListRequest.builder().build()); + } + + /** + * Returns a list of EngagementType objects. + */ + public MergeApiHttpResponse list(EngagementTypesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of EngagementType objects. + */ + public MergeApiHttpResponse list( + EngagementTypesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagement-types"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEngagementTypeList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an EngagementType object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, EngagementTypesRetrieveRequest.builder().build()); + } + + /** + * Returns an EngagementType object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, EngagementTypesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an EngagementType object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, EngagementTypesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagement-types") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EngagementType.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + EngagementTypesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + EngagementTypesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + EngagementTypesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/engagement-types/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/engagementtypes/requests/EngagementTypesRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/engagementtypes/requests/EngagementTypesRetrieveRequest.java index 754172f27..0ca469d9b 100644 --- a/src/main/java/com/merge/api/resources/crm/engagementtypes/requests/EngagementTypesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/engagementtypes/requests/EngagementTypesRetrieveRequest.java @@ -24,14 +24,18 @@ public final class EngagementTypesRetrieveRequest { private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private EngagementTypesRetrieveRequest( Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -51,6 +55,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +76,13 @@ public Map getAdditionalProperties() { private boolean equalTo(EngagementTypesRetrieveRequest other) { return includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -87,6 +100,8 @@ public static final class Builder { private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,6 +110,7 @@ private Builder() {} public Builder from(EngagementTypesRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @@ -120,8 +136,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public EngagementTypesRetrieveRequest build() { - return new EngagementTypesRetrieveRequest(includeRemoteData, includeRemoteFields, additionalProperties); + return new EngagementTypesRetrieveRequest( + includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/fieldmapping/AsyncFieldMappingClient.java b/src/main/java/com/merge/api/resources/crm/fieldmapping/AsyncFieldMappingClient.java new file mode 100644 index 000000000..61ed31f1e --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/fieldmapping/AsyncFieldMappingClient.java @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.fieldmapping; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.crm.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.crm.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.crm.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.crm.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.crm.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.crm.types.FieldMappingInstanceResponse; +import com.merge.api.resources.crm.types.RemoteFieldApiResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncFieldMappingClient { + protected final ClientOptions clientOptions; + + private final AsyncRawFieldMappingClient rawClient; + + public AsyncFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawFieldMappingClient withRawResponse() { + return this.rawClient; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve() { + return this.rawClient.fieldMappingsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return this.rawClient.fieldMappingsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate(CreateFieldMappingRequest request) { + return this.rawClient.fieldMappingsCreate(request).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsCreate(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy(String fieldMappingId) { + return this.rawClient.fieldMappingsDestroy(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate(String fieldMappingId) { + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve() { + return this.rawClient.remoteFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return this.rawClient.remoteFieldsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve() { + return this.rawClient.targetFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve(RequestOptions requestOptions) { + return this.rawClient.targetFieldsRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/fieldmapping/AsyncRawFieldMappingClient.java b/src/main/java/com/merge/api/resources/crm/fieldmapping/AsyncRawFieldMappingClient.java new file mode 100644 index 000000000..e59ca8575 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/fieldmapping/AsyncRawFieldMappingClient.java @@ -0,0 +1,471 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.crm.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.crm.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.crm.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.crm.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.crm.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.crm.types.FieldMappingInstanceResponse; +import com.merge.api.resources.crm.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawFieldMappingClient { + protected final ClientOptions clientOptions; + + public AsyncRawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), RemoteFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/fieldmapping/FieldMappingClient.java b/src/main/java/com/merge/api/resources/crm/fieldmapping/FieldMappingClient.java index 0ada00e54..fe9e132d6 100644 --- a/src/main/java/com/merge/api/resources/crm/fieldmapping/FieldMappingClient.java +++ b/src/main/java/com/merge/api/resources/crm/fieldmapping/FieldMappingClient.java @@ -3,12 +3,7 @@ */ package com.merge.api.resources.crm.fieldmapping; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.fieldmapping.requests.CreateFieldMappingRequest; import com.merge.api.resources.crm.fieldmapping.requests.FieldMappingsRetrieveRequest; @@ -18,36 +13,36 @@ import com.merge.api.resources.crm.types.FieldMappingApiInstanceResponse; import com.merge.api.resources.crm.types.FieldMappingInstanceResponse; import com.merge.api.resources.crm.types.RemoteFieldApiResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class FieldMappingClient { protected final ClientOptions clientOptions; + private final RawFieldMappingClient rawClient; + public FieldMappingClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawFieldMappingClient withRawResponse() { + return this.rawClient; } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve() { - return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + return this.rawClient.fieldMappingsRetrieve().body(); } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrieveRequest request) { - return fieldMappingsRetrieve(request, null); + return this.rawClient.fieldMappingsRetrieve(request).body(); } /** @@ -55,46 +50,14 @@ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrie */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve( FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), FieldMappingApiInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).body(); } /** * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingRequest request) { - return fieldMappingsCreate(request, null); + return this.rawClient.fieldMappingsCreate(request).body(); } /** @@ -102,102 +65,30 @@ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingReques */ public FieldMappingInstanceResponse fieldMappingsCreate( CreateFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("target_field_name", request.getTargetFieldName()); - properties.put("target_field_description", request.getTargetFieldDescription()); - properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); - properties.put("remote_method", request.getRemoteMethod()); - properties.put("remote_url_path", request.getRemoteUrlPath()); - properties.put("common_model_name", request.getCommonModelName()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsCreate(request, requestOptions).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId) { - return fieldMappingsDestroy(fieldMappingId, null); + return this.rawClient.fieldMappingsDestroy(fieldMappingId).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .body(); } /** * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappingId) { - return fieldMappingsPartialUpdate( - fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).body(); } /** @@ -205,7 +96,9 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappi */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request) { - return fieldMappingsPartialUpdate(fieldMappingId, request, null); + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .body(); } /** @@ -213,56 +106,23 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve() { - return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + return this.rawClient.remoteFieldsRetrieve().body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { - return remoteFieldsRetrieve(request, null); + return this.rawClient.remoteFieldsRetrieve(request).body(); } /** @@ -270,80 +130,20 @@ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest r */ public RemoteFieldApiResponse remoteFieldsRetrieve( RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/remote-fields"); - if (request.getCommonModels().isPresent()) { - httpUrl.addQueryParameter("common_models", request.getCommonModels().get()); - } - if (request.getIncludeExampleValues().isPresent()) { - httpUrl.addQueryParameter( - "include_example_values", request.getIncludeExampleValues().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve() { - return targetFieldsRetrieve(null); + return this.rawClient.targetFieldsRetrieve().body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/target-fields") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalTargetFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.targetFieldsRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/fieldmapping/RawFieldMappingClient.java b/src/main/java/com/merge/api/resources/crm/fieldmapping/RawFieldMappingClient.java new file mode 100644 index 000000000..cac7a79db --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/fieldmapping/RawFieldMappingClient.java @@ -0,0 +1,380 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.crm.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.crm.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.crm.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.crm.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.crm.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.crm.types.FieldMappingInstanceResponse; +import com.merge.api.resources.crm.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawFieldMappingClient { + protected final ClientOptions clientOptions; + + public RawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate(CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy(String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate(String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/forceresync/AsyncForceResyncClient.java b/src/main/java/com/merge/api/resources/crm/forceresync/AsyncForceResyncClient.java new file mode 100644 index 000000000..c1eba7144 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/forceresync/AsyncForceResyncClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.forceresync; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.SyncStatus; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncForceResyncClient { + protected final ClientOptions clientOptions; + + private final AsyncRawForceResyncClient rawClient; + + public AsyncForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawForceResyncClient withRawResponse() { + return this.rawClient; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate() { + return this.rawClient.syncStatusResyncCreate().thenApply(response -> response.body()); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate(RequestOptions requestOptions) { + return this.rawClient.syncStatusResyncCreate(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/forceresync/AsyncRawForceResyncClient.java b/src/main/java/com/merge/api/resources/crm/forceresync/AsyncRawForceResyncClient.java new file mode 100644 index 000000000..2d2dfff87 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/forceresync/AsyncRawForceResyncClient.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawForceResyncClient { + protected final ClientOptions clientOptions; + + public AsyncRawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/forceresync/ForceResyncClient.java b/src/main/java/com/merge/api/resources/crm/forceresync/ForceResyncClient.java index 3a4e64883..343825890 100644 --- a/src/main/java/com/merge/api/resources/crm/forceresync/ForceResyncClient.java +++ b/src/main/java/com/merge/api/resources/crm/forceresync/ForceResyncClient.java @@ -3,69 +3,39 @@ */ package com.merge.api.resources.crm.forceresync; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.types.SyncStatus; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ForceResyncClient { protected final ClientOptions clientOptions; + private final RawForceResyncClient rawClient; + public ForceResyncClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawForceResyncClient withRawResponse() { + return this.rawClient; } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate() { - return syncStatusResyncCreate(null); + return this.rawClient.syncStatusResyncCreate().body(); } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/sync-status/resync") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.syncStatusResyncCreate(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/forceresync/RawForceResyncClient.java b/src/main/java/com/merge/api/resources/crm/forceresync/RawForceResyncClient.java new file mode 100644 index 000000000..f03ca3136 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/forceresync/RawForceResyncClient.java @@ -0,0 +1,75 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawForceResyncClient { + protected final ClientOptions clientOptions; + + public RawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/generatekey/AsyncGenerateKeyClient.java b/src/main/java/com/merge/api/resources/crm/generatekey/AsyncGenerateKeyClient.java new file mode 100644 index 000000000..6b44e6edd --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/generatekey/AsyncGenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.generatekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.crm.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncGenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawGenerateKeyClient rawClient; + + public AsyncGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawGenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/generatekey/AsyncRawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/crm/generatekey/AsyncRawGenerateKeyClient.java new file mode 100644 index 000000000..949f440be --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/generatekey/AsyncRawGenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.crm.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public CompletableFuture> create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public CompletableFuture> create( + GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/generatekey/GenerateKeyClient.java b/src/main/java/com/merge/api/resources/crm/generatekey/GenerateKeyClient.java index 442220b6e..713522fb9 100644 --- a/src/main/java/com/merge/api/resources/crm/generatekey/GenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/crm/generatekey/GenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.crm.generatekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.generatekey.requests.GenerateRemoteKeyRequest; import com.merge.api.resources.crm.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class GenerateKeyClient { protected final ClientOptions clientOptions; + private final RawGenerateKeyClient rawClient; + public GenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawGenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/generate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/generatekey/RawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/crm/generatekey/RawGenerateKeyClient.java new file mode 100644 index 000000000..6e28ff3a2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/generatekey/RawGenerateKeyClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.crm.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/issues/AsyncIssuesClient.java b/src/main/java/com/merge/api/resources/crm/issues/AsyncIssuesClient.java new file mode 100644 index 000000000..22fe28e9a --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/issues/AsyncIssuesClient.java @@ -0,0 +1,64 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.issues; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.issues.requests.IssuesListRequest; +import com.merge.api.resources.crm.types.Issue; +import com.merge.api.resources.crm.types.PaginatedIssueList; +import java.util.concurrent.CompletableFuture; + +public class AsyncIssuesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawIssuesClient rawClient; + + public AsyncIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawIssuesClient withRawResponse() { + return this.rawClient; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/issues/AsyncRawIssuesClient.java b/src/main/java/com/merge/api/resources/crm/issues/AsyncRawIssuesClient.java new file mode 100644 index 000000000..ecff2f066 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/issues/AsyncRawIssuesClient.java @@ -0,0 +1,226 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.issues.requests.IssuesListRequest; +import com.merge.api.resources.crm.types.Issue; +import com.merge.api.resources.crm.types.PaginatedIssueList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawIssuesClient { + protected final ClientOptions clientOptions; + + public AsyncRawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list( + IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/issues/IssuesClient.java b/src/main/java/com/merge/api/resources/crm/issues/IssuesClient.java index db1593212..5d1679256 100644 --- a/src/main/java/com/merge/api/resources/crm/issues/IssuesClient.java +++ b/src/main/java/com/merge/api/resources/crm/issues/IssuesClient.java @@ -3,169 +3,61 @@ */ package com.merge.api.resources.crm.issues; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.issues.requests.IssuesListRequest; import com.merge.api.resources.crm.types.Issue; import com.merge.api.resources.crm.types.PaginatedIssueList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class IssuesClient { protected final ClientOptions clientOptions; + private final RawIssuesClient rawClient; + public IssuesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawIssuesClient withRawResponse() { + return this.rawClient; } /** * Gets all issues for Organization. */ public PaginatedIssueList list() { - return list(IssuesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/issues"); - if (request.getAccountToken().isPresent()) { - httpUrl.addQueryParameter("account_token", request.getAccountToken().get()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getFirstIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_after", - request.getFirstIncidentTimeAfter().get().toString()); - } - if (request.getFirstIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_before", - request.getFirstIncidentTimeBefore().get().toString()); - } - if (request.getIncludeMuted().isPresent()) { - httpUrl.addQueryParameter("include_muted", request.getIncludeMuted().get()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getLastIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_after", - request.getLastIncidentTimeAfter().get().toString()); - } - if (request.getLastIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_before", - request.getLastIncidentTimeBefore().get().toString()); - } - if (request.getLinkedAccountId().isPresent()) { - httpUrl.addQueryParameter( - "linked_account_id", request.getLinkedAccountId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Get a specific issue. */ public Issue retrieve(String id) { - return retrieve(id, null); + return this.rawClient.retrieve(id).body(); } /** * Get a specific issue. */ public Issue retrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/issues") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/issues/RawIssuesClient.java b/src/main/java/com/merge/api/resources/crm/issues/RawIssuesClient.java new file mode 100644 index 000000000..c5591500f --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/issues/RawIssuesClient.java @@ -0,0 +1,194 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.issues.requests.IssuesListRequest; +import com.merge.api.resources.crm.types.Issue; +import com.merge.api.resources.crm.types.PaginatedIssueList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawIssuesClient { + protected final ClientOptions clientOptions; + + public RawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/leads/AsyncLeadsClient.java b/src/main/java/com/merge/api/resources/crm/leads/AsyncLeadsClient.java new file mode 100644 index 000000000..f9f4d6034 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/leads/AsyncLeadsClient.java @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.leads; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.leads.requests.LeadEndpointRequest; +import com.merge.api.resources.crm.leads.requests.LeadsListRequest; +import com.merge.api.resources.crm.leads.requests.LeadsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.leads.requests.LeadsRetrieveRequest; +import com.merge.api.resources.crm.types.Lead; +import com.merge.api.resources.crm.types.LeadResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedLeadList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncLeadsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLeadsClient rawClient; + + public AsyncLeadsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLeadsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLeadsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Lead objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Lead objects. + */ + public CompletableFuture list(LeadsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Lead objects. + */ + public CompletableFuture list(LeadsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Lead object with the given values. + */ + public CompletableFuture create(LeadEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Lead object with the given values. + */ + public CompletableFuture create(LeadEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Lead object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Lead object with the given id. + */ + public CompletableFuture retrieve(String id, LeadsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Lead object with the given id. + */ + public CompletableFuture retrieve(String id, LeadsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Lead POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Lead POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + LeadsRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + LeadsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/leads/AsyncRawLeadsClient.java b/src/main/java/com/merge/api/resources/crm/leads/AsyncRawLeadsClient.java new file mode 100644 index 000000000..a650f23ac --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/leads/AsyncRawLeadsClient.java @@ -0,0 +1,527 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.leads; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.leads.requests.LeadEndpointRequest; +import com.merge.api.resources.crm.leads.requests.LeadsListRequest; +import com.merge.api.resources.crm.leads.requests.LeadsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.leads.requests.LeadsRetrieveRequest; +import com.merge.api.resources.crm.types.Lead; +import com.merge.api.resources.crm.types.LeadResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedLeadList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLeadsClient { + protected final ClientOptions clientOptions; + + public AsyncRawLeadsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Lead objects. + */ + public CompletableFuture> list() { + return list(LeadsListRequest.builder().build()); + } + + /** + * Returns a list of Lead objects. + */ + public CompletableFuture> list(LeadsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Lead objects. + */ + public CompletableFuture> list( + LeadsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/leads"); + if (request.getConvertedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "converted_account_id", + request.getConvertedAccountId().get(), + false); + } + if (request.getConvertedContactId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "converted_contact_id", + request.getConvertedContactId().get(), + false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmailAddresses().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email_addresses", request.getEmailAddresses().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOwnerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "owner_id", request.getOwnerId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPhoneNumbers().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "phone_numbers", request.getPhoneNumbers().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedLeadList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Lead object with the given values. + */ + public CompletableFuture> create(LeadEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Lead object with the given values. + */ + public CompletableFuture> create( + LeadEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/leads"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LeadResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Lead object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, LeadsRetrieveRequest.builder().build()); + } + + /** + * Returns a Lead object with the given id. + */ + public CompletableFuture> retrieve(String id, LeadsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Lead object with the given id. + */ + public CompletableFuture> retrieve( + String id, LeadsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/leads") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Lead.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Lead POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Lead POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/leads/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + LeadsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + LeadsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + LeadsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/leads/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/leads/LeadsClient.java b/src/main/java/com/merge/api/resources/crm/leads/LeadsClient.java index 96ed22061..e097b21fa 100644 --- a/src/main/java/com/merge/api/resources/crm/leads/LeadsClient.java +++ b/src/main/java/com/merge/api/resources/crm/leads/LeadsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.crm.leads; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.leads.requests.LeadEndpointRequest; import com.merge.api.resources.crm.leads.requests.LeadsListRequest; @@ -18,305 +14,106 @@ import com.merge.api.resources.crm.types.MetaResponse; import com.merge.api.resources.crm.types.PaginatedLeadList; import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LeadsClient { protected final ClientOptions clientOptions; + private final RawLeadsClient rawClient; + public LeadsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLeadsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLeadsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Lead objects. */ public PaginatedLeadList list() { - return list(LeadsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Lead objects. */ public PaginatedLeadList list(LeadsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Lead objects. */ public PaginatedLeadList list(LeadsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/leads"); - if (request.getConvertedAccountId().isPresent()) { - httpUrl.addQueryParameter( - "converted_account_id", request.getConvertedAccountId().get()); - } - if (request.getConvertedContactId().isPresent()) { - httpUrl.addQueryParameter( - "converted_contact_id", request.getConvertedContactId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmailAddresses().isPresent()) { - httpUrl.addQueryParameter( - "email_addresses", request.getEmailAddresses().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getOwnerId().isPresent()) { - httpUrl.addQueryParameter("owner_id", request.getOwnerId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getPhoneNumbers().isPresent()) { - httpUrl.addQueryParameter("phone_numbers", request.getPhoneNumbers().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedLeadList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Lead object with the given values. */ public LeadResponse create(LeadEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Lead object with the given values. */ public LeadResponse create(LeadEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/leads"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LeadResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Lead object with the given id. */ public Lead retrieve(String id) { - return retrieve(id, LeadsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Lead object with the given id. */ public Lead retrieve(String id, LeadsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Lead object with the given id. */ public Lead retrieve(String id, LeadsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/leads") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Lead.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for Lead POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Lead POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/leads/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - LeadsRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(LeadsRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -324,61 +121,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(LeadsRemoteFieldClas */ public PaginatedRemoteFieldClassList remoteFieldClassesList( LeadsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/leads/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/leads/RawLeadsClient.java b/src/main/java/com/merge/api/resources/crm/leads/RawLeadsClient.java new file mode 100644 index 000000000..bf5e47359 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/leads/RawLeadsClient.java @@ -0,0 +1,451 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.leads; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.leads.requests.LeadEndpointRequest; +import com.merge.api.resources.crm.leads.requests.LeadsListRequest; +import com.merge.api.resources.crm.leads.requests.LeadsRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.leads.requests.LeadsRetrieveRequest; +import com.merge.api.resources.crm.types.Lead; +import com.merge.api.resources.crm.types.LeadResponse; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedLeadList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLeadsClient { + protected final ClientOptions clientOptions; + + public RawLeadsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Lead objects. + */ + public MergeApiHttpResponse list() { + return list(LeadsListRequest.builder().build()); + } + + /** + * Returns a list of Lead objects. + */ + public MergeApiHttpResponse list(LeadsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Lead objects. + */ + public MergeApiHttpResponse list(LeadsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/leads"); + if (request.getConvertedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "converted_account_id", + request.getConvertedAccountId().get(), + false); + } + if (request.getConvertedContactId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "converted_contact_id", + request.getConvertedContactId().get(), + false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmailAddresses().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email_addresses", request.getEmailAddresses().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOwnerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "owner_id", request.getOwnerId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPhoneNumbers().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "phone_numbers", request.getPhoneNumbers().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedLeadList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Lead object with the given values. + */ + public MergeApiHttpResponse create(LeadEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Lead object with the given values. + */ + public MergeApiHttpResponse create(LeadEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/leads"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LeadResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Lead object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, LeadsRetrieveRequest.builder().build()); + } + + /** + * Returns a Lead object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, LeadsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Lead object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, LeadsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/leads") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Lead.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Lead POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Lead POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/leads/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + LeadsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + LeadsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + LeadsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/leads/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/leads/requests/LeadsListRequest.java b/src/main/java/com/merge/api/resources/crm/leads/requests/LeadsListRequest.java index 3a72e5898..910b4c0cb 100644 --- a/src/main/java/com/merge/api/resources/crm/leads/requests/LeadsListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/leads/requests/LeadsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.leads.types.LeadsListRequestExpand; +import com.merge.api.resources.crm.leads.types.LeadsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LeadsListRequest.Builder.class) public final class LeadsListRequest { + private final Optional> expand; + private final Optional convertedAccountId; private final Optional convertedContactId; @@ -34,8 +38,6 @@ public final class LeadsListRequest { private final Optional emailAddresses; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -59,13 +61,13 @@ public final class LeadsListRequest { private final Map additionalProperties; private LeadsListRequest( + Optional> expand, Optional convertedAccountId, Optional convertedContactId, Optional createdAfter, Optional createdBefore, Optional cursor, Optional emailAddresses, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -77,13 +79,13 @@ private LeadsListRequest( Optional phoneNumbers, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.convertedAccountId = convertedAccountId; this.convertedContactId = convertedContactId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.emailAddresses = emailAddresses; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -97,6 +99,14 @@ private LeadsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return leads with this account. */ @@ -145,14 +155,6 @@ public Optional getEmailAddresses() { return emailAddresses; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -245,13 +247,13 @@ public Map getAdditionalProperties() { } private boolean equalTo(LeadsListRequest other) { - return convertedAccountId.equals(other.convertedAccountId) + return expand.equals(other.expand) + && convertedAccountId.equals(other.convertedAccountId) && convertedContactId.equals(other.convertedContactId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && emailAddresses.equals(other.emailAddresses) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -267,13 +269,13 @@ private boolean equalTo(LeadsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.convertedAccountId, this.convertedContactId, this.createdAfter, this.createdBefore, this.cursor, this.emailAddresses, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -297,6 +299,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional convertedAccountId = Optional.empty(); private Optional convertedContactId = Optional.empty(); @@ -309,8 +313,6 @@ public static final class Builder { private Optional emailAddresses = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -337,13 +339,13 @@ public static final class Builder { private Builder() {} public Builder from(LeadsListRequest other) { + expand(other.getExpand()); convertedAccountId(other.getConvertedAccountId()); convertedContactId(other.getConvertedContactId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); emailAddresses(other.getEmailAddresses()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -357,6 +359,22 @@ public Builder from(LeadsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(LeadsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "converted_account_id", nulls = Nulls.SKIP) public Builder convertedAccountId(Optional convertedAccountId) { this.convertedAccountId = convertedAccountId; @@ -423,17 +441,6 @@ public Builder emailAddresses(String emailAddresses) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(LeadsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -546,13 +553,13 @@ public Builder remoteId(String remoteId) { public LeadsListRequest build() { return new LeadsListRequest( + expand, convertedAccountId, convertedContactId, createdAfter, createdBefore, cursor, emailAddresses, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/crm/leads/requests/LeadsRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/leads/requests/LeadsRetrieveRequest.java index f2bcc2488..eaf64833c 100644 --- a/src/main/java/com/merge/api/resources/crm/leads/requests/LeadsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/leads/requests/LeadsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.leads.types.LeadsRetrieveRequestExpand; +import com.merge.api.resources.crm.leads.types.LeadsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,22 +23,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = LeadsRetrieveRequest.Builder.class) public final class LeadsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private LeadsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -44,7 +50,7 @@ private LeadsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -64,6 +70,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -78,12 +92,13 @@ public Map getAdditionalProperties() { private boolean equalTo(LeadsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -97,12 +112,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -112,20 +129,26 @@ public Builder from(LeadsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(LeadsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(LeadsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -148,8 +171,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public LeadsRetrieveRequest build() { - return new LeadsRetrieveRequest(expand, includeRemoteData, includeRemoteFields, additionalProperties); + return new LeadsRetrieveRequest( + expand, includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/leads/types/LeadsListRequestExpand.java b/src/main/java/com/merge/api/resources/crm/leads/types/LeadsListRequestExpand.java deleted file mode 100644 index 77762ad40..000000000 --- a/src/main/java/com/merge/api/resources/crm/leads/types/LeadsListRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.leads.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum LeadsListRequestExpand { - CONVERTED_ACCOUNT("converted_account"), - - CONVERTED_CONTACT("converted_contact"), - - CONVERTED_CONTACT_CONVERTED_ACCOUNT("converted_contact,converted_account"), - - OWNER("owner"), - - OWNER_CONVERTED_ACCOUNT("owner,converted_account"), - - OWNER_CONVERTED_CONTACT("owner,converted_contact"), - - OWNER_CONVERTED_CONTACT_CONVERTED_ACCOUNT("owner,converted_contact,converted_account"); - - private final String value; - - LeadsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/leads/types/LeadsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/leads/types/LeadsListRequestExpandItem.java new file mode 100644 index 000000000..191a68984 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/leads/types/LeadsListRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.leads.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum LeadsListRequestExpandItem { + CONVERTED_ACCOUNT("converted_account"), + + CONVERTED_CONTACT("converted_contact"), + + OWNER("owner"); + + private final String value; + + LeadsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/leads/types/LeadsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/crm/leads/types/LeadsRetrieveRequestExpand.java deleted file mode 100644 index d3d33603b..000000000 --- a/src/main/java/com/merge/api/resources/crm/leads/types/LeadsRetrieveRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.leads.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum LeadsRetrieveRequestExpand { - CONVERTED_ACCOUNT("converted_account"), - - CONVERTED_CONTACT("converted_contact"), - - CONVERTED_CONTACT_CONVERTED_ACCOUNT("converted_contact,converted_account"), - - OWNER("owner"), - - OWNER_CONVERTED_ACCOUNT("owner,converted_account"), - - OWNER_CONVERTED_CONTACT("owner,converted_contact"), - - OWNER_CONVERTED_CONTACT_CONVERTED_ACCOUNT("owner,converted_contact,converted_account"); - - private final String value; - - LeadsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/leads/types/LeadsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/leads/types/LeadsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..759020d2e --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/leads/types/LeadsRetrieveRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.leads.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum LeadsRetrieveRequestExpandItem { + CONVERTED_ACCOUNT("converted_account"), + + CONVERTED_CONTACT("converted_contact"), + + OWNER("owner"); + + private final String value; + + LeadsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/linkedaccounts/AsyncLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/crm/linkedaccounts/AsyncLinkedAccountsClient.java new file mode 100644 index 000000000..1ed5674d4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/linkedaccounts/AsyncLinkedAccountsClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.linkedaccounts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.crm.types.PaginatedAccountDetailsAndActionsList; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkedAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkedAccountsClient rawClient; + + public AsyncLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkedAccountsClient withRawResponse() { + return this.rawClient; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list(LinkedAccountsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/linkedaccounts/AsyncRawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/crm/linkedaccounts/AsyncRawLinkedAccountsClient.java new file mode 100644 index 000000000..19d23718d --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/linkedaccounts/AsyncRawLinkedAccountsClient.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.crm.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/linkedaccounts/LinkedAccountsClient.java b/src/main/java/com/merge/api/resources/crm/linkedaccounts/LinkedAccountsClient.java index 1125fcb7a..a7fc330cc 100644 --- a/src/main/java/com/merge/api/resources/crm/linkedaccounts/LinkedAccountsClient.java +++ b/src/main/java/com/merge/api/resources/crm/linkedaccounts/LinkedAccountsClient.java @@ -3,40 +3,40 @@ */ package com.merge.api.resources.crm.linkedaccounts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.linkedaccounts.requests.LinkedAccountsListRequest; import com.merge.api.resources.crm.types.PaginatedAccountDetailsAndActionsList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkedAccountsClient { protected final ClientOptions clientOptions; + private final RawLinkedAccountsClient rawClient; + public LinkedAccountsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkedAccountsClient withRawResponse() { + return this.rawClient; } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list() { - return list(LinkedAccountsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** @@ -44,80 +44,6 @@ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest requ */ public PaginatedAccountDetailsAndActionsList list( LinkedAccountsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/linked-accounts"); - if (request.getCategory().isPresent()) { - httpUrl.addQueryParameter("category", request.getCategory().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndUserEmailAddress().isPresent()) { - httpUrl.addQueryParameter( - "end_user_email_address", request.getEndUserEmailAddress().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getEndUserOriginId().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_id", request.getEndUserOriginId().get()); - } - if (request.getEndUserOriginIds().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_ids", request.getEndUserOriginIds().get()); - } - if (request.getId().isPresent()) { - httpUrl.addQueryParameter("id", request.getId().get()); - } - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getIncludeDuplicates().isPresent()) { - httpUrl.addQueryParameter( - "include_duplicates", request.getIncludeDuplicates().get().toString()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getIsTestAccount().isPresent()) { - httpUrl.addQueryParameter( - "is_test_account", request.getIsTestAccount().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedAccountDetailsAndActionsList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/linkedaccounts/RawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/crm/linkedaccounts/RawLinkedAccountsClient.java new file mode 100644 index 000000000..592b61841 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/linkedaccounts/RawLinkedAccountsClient.java @@ -0,0 +1,143 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.crm.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public RawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list(LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/linktoken/AsyncLinkTokenClient.java b/src/main/java/com/merge/api/resources/crm/linktoken/AsyncLinkTokenClient.java new file mode 100644 index 000000000..d737f90e2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/linktoken/AsyncLinkTokenClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.linktoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.crm.types.LinkToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkTokenClient rawClient; + + public AsyncLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/linktoken/AsyncRawLinkTokenClient.java b/src/main/java/com/merge/api/resources/crm/linktoken/AsyncRawLinkTokenClient.java new file mode 100644 index 000000000..9b2bc2f51 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/linktoken/AsyncRawLinkTokenClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.crm.types.LinkToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create( + EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/linktoken/LinkTokenClient.java b/src/main/java/com/merge/api/resources/crm/linktoken/LinkTokenClient.java index 73be11092..e3d6e2662 100644 --- a/src/main/java/com/merge/api/resources/crm/linktoken/LinkTokenClient.java +++ b/src/main/java/com/merge/api/resources/crm/linktoken/LinkTokenClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.crm.linktoken; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.linktoken.requests.EndUserDetailsRequest; import com.merge.api.resources.crm.types.LinkToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkTokenClient { protected final ClientOptions clientOptions; + private final RawLinkTokenClient rawClient; + public LinkTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkTokenClient withRawResponse() { + return this.rawClient; } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/link-token") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/linktoken/RawLinkTokenClient.java b/src/main/java/com/merge/api/resources/crm/linktoken/RawLinkTokenClient.java new file mode 100644 index 000000000..eba26245d --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/linktoken/RawLinkTokenClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.crm.types.LinkToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkTokenClient { + protected final ClientOptions clientOptions; + + public RawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/notes/AsyncNotesClient.java b/src/main/java/com/merge/api/resources/crm/notes/AsyncNotesClient.java new file mode 100644 index 000000000..7e8ced46a --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/notes/AsyncNotesClient.java @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.notes; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.notes.requests.NoteEndpointRequest; +import com.merge.api.resources.crm.notes.requests.NotesListRequest; +import com.merge.api.resources.crm.notes.requests.NotesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.notes.requests.NotesRetrieveRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.Note; +import com.merge.api.resources.crm.types.NoteResponse; +import com.merge.api.resources.crm.types.PaginatedNoteList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncNotesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawNotesClient rawClient; + + public AsyncNotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawNotesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawNotesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Note objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Note objects. + */ + public CompletableFuture list(NotesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Note objects. + */ + public CompletableFuture list(NotesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Note object with the given values. + */ + public CompletableFuture create(NoteEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Note object with the given values. + */ + public CompletableFuture create(NoteEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Note object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Note object with the given id. + */ + public CompletableFuture retrieve(String id, NotesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Note object with the given id. + */ + public CompletableFuture retrieve(String id, NotesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Note POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Note POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + NotesRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + NotesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/notes/AsyncRawNotesClient.java b/src/main/java/com/merge/api/resources/crm/notes/AsyncRawNotesClient.java new file mode 100644 index 000000000..3becd0478 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/notes/AsyncRawNotesClient.java @@ -0,0 +1,517 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.notes; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.notes.requests.NoteEndpointRequest; +import com.merge.api.resources.crm.notes.requests.NotesListRequest; +import com.merge.api.resources.crm.notes.requests.NotesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.notes.requests.NotesRetrieveRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.Note; +import com.merge.api.resources.crm.types.NoteResponse; +import com.merge.api.resources.crm.types.PaginatedNoteList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawNotesClient { + protected final ClientOptions clientOptions; + + public AsyncRawNotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Note objects. + */ + public CompletableFuture> list() { + return list(NotesListRequest.builder().build()); + } + + /** + * Returns a list of Note objects. + */ + public CompletableFuture> list(NotesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Note objects. + */ + public CompletableFuture> list( + NotesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/notes"); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } + if (request.getContactId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "contact_id", request.getContactId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOpportunityId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "opportunity_id", request.getOpportunityId().get(), false); + } + if (request.getOwnerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "owner_id", request.getOwnerId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNoteList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Note object with the given values. + */ + public CompletableFuture> create(NoteEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Note object with the given values. + */ + public CompletableFuture> create( + NoteEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/notes"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NoteResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Note object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, NotesRetrieveRequest.builder().build()); + } + + /** + * Returns a Note object with the given id. + */ + public CompletableFuture> retrieve(String id, NotesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Note object with the given id. + */ + public CompletableFuture> retrieve( + String id, NotesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/notes") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Note POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Note POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/notes/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + NotesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + NotesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + NotesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/notes/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/notes/NotesClient.java b/src/main/java/com/merge/api/resources/crm/notes/NotesClient.java index 15a603cca..c7008bc87 100644 --- a/src/main/java/com/merge/api/resources/crm/notes/NotesClient.java +++ b/src/main/java/com/merge/api/resources/crm/notes/NotesClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.crm.notes; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.notes.requests.NoteEndpointRequest; import com.merge.api.resources.crm.notes.requests.NotesListRequest; @@ -18,300 +14,106 @@ import com.merge.api.resources.crm.types.NoteResponse; import com.merge.api.resources.crm.types.PaginatedNoteList; import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class NotesClient { protected final ClientOptions clientOptions; + private final RawNotesClient rawClient; + public NotesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawNotesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawNotesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Note objects. */ public PaginatedNoteList list() { - return list(NotesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Note objects. */ public PaginatedNoteList list(NotesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Note objects. */ public PaginatedNoteList list(NotesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/notes"); - if (request.getAccountId().isPresent()) { - httpUrl.addQueryParameter("account_id", request.getAccountId().get()); - } - if (request.getContactId().isPresent()) { - httpUrl.addQueryParameter("contact_id", request.getContactId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getOpportunityId().isPresent()) { - httpUrl.addQueryParameter( - "opportunity_id", request.getOpportunityId().get()); - } - if (request.getOwnerId().isPresent()) { - httpUrl.addQueryParameter("owner_id", request.getOwnerId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNoteList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Note object with the given values. */ public NoteResponse create(NoteEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Note object with the given values. */ public NoteResponse create(NoteEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/notes"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NoteResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Note object with the given id. */ public Note retrieve(String id) { - return retrieve(id, NotesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Note object with the given id. */ public Note retrieve(String id, NotesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Note object with the given id. */ public Note retrieve(String id, NotesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/notes") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for Note POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Note POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/notes/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - NotesRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(NotesRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -319,61 +121,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(NotesRemoteFieldClas */ public PaginatedRemoteFieldClassList remoteFieldClassesList( NotesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/notes/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/notes/RawNotesClient.java b/src/main/java/com/merge/api/resources/crm/notes/RawNotesClient.java new file mode 100644 index 000000000..3a1aa1f06 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/notes/RawNotesClient.java @@ -0,0 +1,441 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.notes; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.notes.requests.NoteEndpointRequest; +import com.merge.api.resources.crm.notes.requests.NotesListRequest; +import com.merge.api.resources.crm.notes.requests.NotesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.notes.requests.NotesRetrieveRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.Note; +import com.merge.api.resources.crm.types.NoteResponse; +import com.merge.api.resources.crm.types.PaginatedNoteList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawNotesClient { + protected final ClientOptions clientOptions; + + public RawNotesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Note objects. + */ + public MergeApiHttpResponse list() { + return list(NotesListRequest.builder().build()); + } + + /** + * Returns a list of Note objects. + */ + public MergeApiHttpResponse list(NotesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Note objects. + */ + public MergeApiHttpResponse list(NotesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/notes"); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } + if (request.getContactId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "contact_id", request.getContactId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOpportunityId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "opportunity_id", request.getOpportunityId().get(), false); + } + if (request.getOwnerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "owner_id", request.getOwnerId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedNoteList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Note object with the given values. + */ + public MergeApiHttpResponse create(NoteEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Note object with the given values. + */ + public MergeApiHttpResponse create(NoteEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/notes"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NoteResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Note object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, NotesRetrieveRequest.builder().build()); + } + + /** + * Returns a Note object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, NotesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Note object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, NotesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/notes") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Note.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Note POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Note POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/notes/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + NotesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + NotesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + NotesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/notes/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/notes/requests/NotesListRequest.java b/src/main/java/com/merge/api/resources/crm/notes/requests/NotesListRequest.java index d8f262df1..05af26017 100644 --- a/src/main/java/com/merge/api/resources/crm/notes/requests/NotesListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/notes/requests/NotesListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.notes.types.NotesListRequestExpand; +import com.merge.api.resources.crm.notes.types.NotesListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = NotesListRequest.Builder.class) public final class NotesListRequest { + private final Optional> expand; + private final Optional accountId; private final Optional contactId; @@ -32,8 +36,6 @@ public final class NotesListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -57,12 +59,12 @@ public final class NotesListRequest { private final Map additionalProperties; private NotesListRequest( + Optional> expand, Optional accountId, Optional contactId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -74,12 +76,12 @@ private NotesListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.accountId = accountId; this.contactId = contactId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -93,6 +95,14 @@ private NotesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return notes with this account. */ @@ -133,14 +143,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -233,12 +235,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(NotesListRequest other) { - return accountId.equals(other.accountId) + return expand.equals(other.expand) + && accountId.equals(other.accountId) && contactId.equals(other.contactId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -254,12 +256,12 @@ private boolean equalTo(NotesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.accountId, this.contactId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -283,6 +285,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional accountId = Optional.empty(); private Optional contactId = Optional.empty(); @@ -293,8 +297,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -321,12 +323,12 @@ public static final class Builder { private Builder() {} public Builder from(NotesListRequest other) { + expand(other.getExpand()); accountId(other.getAccountId()); contactId(other.getContactId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -340,6 +342,22 @@ public Builder from(NotesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(NotesListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "account_id", nulls = Nulls.SKIP) public Builder accountId(Optional accountId) { this.accountId = accountId; @@ -395,17 +413,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(NotesListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -518,12 +525,12 @@ public Builder remoteId(String remoteId) { public NotesListRequest build() { return new NotesListRequest( + expand, accountId, contactId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/crm/notes/requests/NotesRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/notes/requests/NotesRetrieveRequest.java index 56513563e..dfb7ab6e1 100644 --- a/src/main/java/com/merge/api/resources/crm/notes/requests/NotesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/notes/requests/NotesRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.notes.types.NotesRetrieveRequestExpand; +import com.merge.api.resources.crm.notes.types.NotesRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,22 +23,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = NotesRetrieveRequest.Builder.class) public final class NotesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private NotesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -44,7 +50,7 @@ private NotesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -64,6 +70,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -78,12 +92,13 @@ public Map getAdditionalProperties() { private boolean equalTo(NotesRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -97,12 +112,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -112,20 +129,26 @@ public Builder from(NotesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(NotesRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(NotesRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -148,8 +171,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public NotesRetrieveRequest build() { - return new NotesRetrieveRequest(expand, includeRemoteData, includeRemoteFields, additionalProperties); + return new NotesRetrieveRequest( + expand, includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/notes/types/NotesListRequestExpand.java b/src/main/java/com/merge/api/resources/crm/notes/types/NotesListRequestExpand.java deleted file mode 100644 index 69d41ebda..000000000 --- a/src/main/java/com/merge/api/resources/crm/notes/types/NotesListRequestExpand.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.notes.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum NotesListRequestExpand { - ACCOUNT("account"), - - ACCOUNT_OPPORTUNITY("account,opportunity"), - - CONTACT("contact"), - - CONTACT_ACCOUNT("contact,account"), - - CONTACT_ACCOUNT_OPPORTUNITY("contact,account,opportunity"), - - CONTACT_OPPORTUNITY("contact,opportunity"), - - OPPORTUNITY("opportunity"), - - OWNER("owner"), - - OWNER_ACCOUNT("owner,account"), - - OWNER_ACCOUNT_OPPORTUNITY("owner,account,opportunity"), - - OWNER_CONTACT("owner,contact"), - - OWNER_CONTACT_ACCOUNT("owner,contact,account"), - - OWNER_CONTACT_ACCOUNT_OPPORTUNITY("owner,contact,account,opportunity"), - - OWNER_CONTACT_OPPORTUNITY("owner,contact,opportunity"), - - OWNER_OPPORTUNITY("owner,opportunity"); - - private final String value; - - NotesListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/notes/types/NotesListRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/notes/types/NotesListRequestExpandItem.java new file mode 100644 index 000000000..a78a4a072 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/notes/types/NotesListRequestExpandItem.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.notes.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum NotesListRequestExpandItem { + ACCOUNT("account"), + + CONTACT("contact"), + + OPPORTUNITY("opportunity"), + + OWNER("owner"); + + private final String value; + + NotesListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/notes/types/NotesRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/crm/notes/types/NotesRetrieveRequestExpand.java deleted file mode 100644 index edca42556..000000000 --- a/src/main/java/com/merge/api/resources/crm/notes/types/NotesRetrieveRequestExpand.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.notes.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum NotesRetrieveRequestExpand { - ACCOUNT("account"), - - ACCOUNT_OPPORTUNITY("account,opportunity"), - - CONTACT("contact"), - - CONTACT_ACCOUNT("contact,account"), - - CONTACT_ACCOUNT_OPPORTUNITY("contact,account,opportunity"), - - CONTACT_OPPORTUNITY("contact,opportunity"), - - OPPORTUNITY("opportunity"), - - OWNER("owner"), - - OWNER_ACCOUNT("owner,account"), - - OWNER_ACCOUNT_OPPORTUNITY("owner,account,opportunity"), - - OWNER_CONTACT("owner,contact"), - - OWNER_CONTACT_ACCOUNT("owner,contact,account"), - - OWNER_CONTACT_ACCOUNT_OPPORTUNITY("owner,contact,account,opportunity"), - - OWNER_CONTACT_OPPORTUNITY("owner,contact,opportunity"), - - OWNER_OPPORTUNITY("owner,opportunity"); - - private final String value; - - NotesRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/notes/types/NotesRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/notes/types/NotesRetrieveRequestExpandItem.java new file mode 100644 index 000000000..d311f1589 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/notes/types/NotesRetrieveRequestExpandItem.java @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.notes.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum NotesRetrieveRequestExpandItem { + ACCOUNT("account"), + + CONTACT("contact"), + + OPPORTUNITY("opportunity"), + + OWNER("owner"); + + private final String value; + + NotesRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/opportunities/AsyncOpportunitiesClient.java b/src/main/java/com/merge/api/resources/crm/opportunities/AsyncOpportunitiesClient.java new file mode 100644 index 000000000..1f4d001d6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/opportunities/AsyncOpportunitiesClient.java @@ -0,0 +1,161 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.opportunities; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.opportunities.requests.OpportunitiesListRequest; +import com.merge.api.resources.crm.opportunities.requests.OpportunitiesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.opportunities.requests.OpportunitiesRetrieveRequest; +import com.merge.api.resources.crm.opportunities.requests.OpportunityEndpointRequest; +import com.merge.api.resources.crm.opportunities.requests.PatchedOpportunityEndpointRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.Opportunity; +import com.merge.api.resources.crm.types.OpportunityResponse; +import com.merge.api.resources.crm.types.PaginatedOpportunityList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.util.concurrent.CompletableFuture; + +public class AsyncOpportunitiesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawOpportunitiesClient rawClient; + + public AsyncOpportunitiesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawOpportunitiesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawOpportunitiesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Opportunity objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Opportunity objects. + */ + public CompletableFuture list(OpportunitiesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Opportunity objects. + */ + public CompletableFuture list( + OpportunitiesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Opportunity object with the given values. + */ + public CompletableFuture create(OpportunityEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Opportunity object with the given values. + */ + public CompletableFuture create( + OpportunityEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Opportunity object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Opportunity object with the given id. + */ + public CompletableFuture retrieve(String id, OpportunitiesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Opportunity object with the given id. + */ + public CompletableFuture retrieve( + String id, OpportunitiesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates an Opportunity object with the given id. + */ + public CompletableFuture partialUpdate(String id, PatchedOpportunityEndpointRequest request) { + return this.rawClient.partialUpdate(id, request).thenApply(response -> response.body()); + } + + /** + * Updates an Opportunity object with the given id. + */ + public CompletableFuture partialUpdate( + String id, PatchedOpportunityEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.partialUpdate(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Opportunity PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id) { + return this.rawClient.metaPatchRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Opportunity PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id, RequestOptions requestOptions) { + return this.rawClient.metaPatchRetrieve(id, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Opportunity POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Opportunity POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + OpportunitiesRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + OpportunitiesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/opportunities/AsyncRawOpportunitiesClient.java b/src/main/java/com/merge/api/resources/crm/opportunities/AsyncRawOpportunitiesClient.java new file mode 100644 index 000000000..5e3208c2d --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/opportunities/AsyncRawOpportunitiesClient.java @@ -0,0 +1,679 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.opportunities; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.opportunities.requests.OpportunitiesListRequest; +import com.merge.api.resources.crm.opportunities.requests.OpportunitiesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.opportunities.requests.OpportunitiesRetrieveRequest; +import com.merge.api.resources.crm.opportunities.requests.OpportunityEndpointRequest; +import com.merge.api.resources.crm.opportunities.requests.PatchedOpportunityEndpointRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.Opportunity; +import com.merge.api.resources.crm.types.OpportunityResponse; +import com.merge.api.resources.crm.types.PaginatedOpportunityList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawOpportunitiesClient { + protected final ClientOptions clientOptions; + + public AsyncRawOpportunitiesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Opportunity objects. + */ + public CompletableFuture> list() { + return list(OpportunitiesListRequest.builder().build()); + } + + /** + * Returns a list of Opportunity objects. + */ + public CompletableFuture> list(OpportunitiesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Opportunity objects. + */ + public CompletableFuture> list( + OpportunitiesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities"); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOwnerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "owner_id", request.getOwnerId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_created_after", + request.getRemoteCreatedAfter().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getStageId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "stage_id", request.getStageId().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedOpportunityList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Opportunity object with the given values. + */ + public CompletableFuture> create(OpportunityEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Opportunity object with the given values. + */ + public CompletableFuture> create( + OpportunityEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), OpportunityResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Opportunity object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, OpportunitiesRetrieveRequest.builder().build()); + } + + /** + * Returns an Opportunity object with the given id. + */ + public CompletableFuture> retrieve( + String id, OpportunitiesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Opportunity object with the given id. + */ + public CompletableFuture> retrieve( + String id, OpportunitiesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Opportunity.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Updates an Opportunity object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedOpportunityEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates an Opportunity object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedOpportunityEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), OpportunityResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Opportunity PATCHs. + */ + public CompletableFuture> metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Opportunity PATCHs. + */ + public CompletableFuture> metaPatchRetrieve( + String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Opportunity POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Opportunity POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + OpportunitiesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + OpportunitiesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + OpportunitiesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/opportunities/OpportunitiesClient.java b/src/main/java/com/merge/api/resources/crm/opportunities/OpportunitiesClient.java index f81ea59cb..8c36137bf 100644 --- a/src/main/java/com/merge/api/resources/crm/opportunities/OpportunitiesClient.java +++ b/src/main/java/com/merge/api/resources/crm/opportunities/OpportunitiesClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.crm.opportunities; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.opportunities.requests.OpportunitiesListRequest; import com.merge.api.resources.crm.opportunities.requests.OpportunitiesRemoteFieldClassesListRequest; @@ -19,269 +15,85 @@ import com.merge.api.resources.crm.types.OpportunityResponse; import com.merge.api.resources.crm.types.PaginatedOpportunityList; import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class OpportunitiesClient { protected final ClientOptions clientOptions; + private final RawOpportunitiesClient rawClient; + public OpportunitiesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawOpportunitiesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawOpportunitiesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Opportunity objects. */ public PaginatedOpportunityList list() { - return list(OpportunitiesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Opportunity objects. */ public PaginatedOpportunityList list(OpportunitiesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Opportunity objects. */ public PaginatedOpportunityList list(OpportunitiesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/opportunities"); - if (request.getAccountId().isPresent()) { - httpUrl.addQueryParameter("account_id", request.getAccountId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getOwnerId().isPresent()) { - httpUrl.addQueryParameter("owner_id", request.getOwnerId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "remote_created_after", - request.getRemoteCreatedAfter().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - if (request.getStageId().isPresent()) { - httpUrl.addQueryParameter("stage_id", request.getStageId().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedOpportunityList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates an Opportunity object with the given values. */ public OpportunityResponse create(OpportunityEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates an Opportunity object with the given values. */ public OpportunityResponse create(OpportunityEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/opportunities"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), OpportunityResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Opportunity object with the given id. */ public Opportunity retrieve(String id) { - return retrieve(id, OpportunitiesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Opportunity object with the given id. */ public Opportunity retrieve(String id, OpportunitiesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Opportunity object with the given id. */ public Opportunity retrieve(String id, OpportunitiesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/opportunities") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Opportunity.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Updates an Opportunity object with the given id. */ public OpportunityResponse partialUpdate(String id, PatchedOpportunityEndpointRequest request) { - return partialUpdate(id, request, null); + return this.rawClient.partialUpdate(id, request).body(); } /** @@ -289,148 +101,49 @@ public OpportunityResponse partialUpdate(String id, PatchedOpportunityEndpointRe */ public OpportunityResponse partialUpdate( String id, PatchedOpportunityEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/opportunities") - .addPathSegment(id); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), OpportunityResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.partialUpdate(id, request, requestOptions).body(); } /** * Returns metadata for Opportunity PATCHs. */ public MetaResponse metaPatchRetrieve(String id) { - return metaPatchRetrieve(id, null); + return this.rawClient.metaPatchRetrieve(id).body(); } /** * Returns metadata for Opportunity PATCHs. */ public MetaResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/opportunities/meta/patch") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPatchRetrieve(id, requestOptions).body(); } /** * Returns metadata for Opportunity POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Opportunity POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/opportunities/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - OpportunitiesRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(OpportunitiesRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -438,61 +151,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(OpportunitiesRemoteF */ public PaginatedRemoteFieldClassList remoteFieldClassesList( OpportunitiesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/opportunities/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/opportunities/RawOpportunitiesClient.java b/src/main/java/com/merge/api/resources/crm/opportunities/RawOpportunitiesClient.java new file mode 100644 index 000000000..94f61e040 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/opportunities/RawOpportunitiesClient.java @@ -0,0 +1,577 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.opportunities; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.opportunities.requests.OpportunitiesListRequest; +import com.merge.api.resources.crm.opportunities.requests.OpportunitiesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.opportunities.requests.OpportunitiesRetrieveRequest; +import com.merge.api.resources.crm.opportunities.requests.OpportunityEndpointRequest; +import com.merge.api.resources.crm.opportunities.requests.PatchedOpportunityEndpointRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.Opportunity; +import com.merge.api.resources.crm.types.OpportunityResponse; +import com.merge.api.resources.crm.types.PaginatedOpportunityList; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawOpportunitiesClient { + protected final ClientOptions clientOptions; + + public RawOpportunitiesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Opportunity objects. + */ + public MergeApiHttpResponse list() { + return list(OpportunitiesListRequest.builder().build()); + } + + /** + * Returns a list of Opportunity objects. + */ + public MergeApiHttpResponse list(OpportunitiesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Opportunity objects. + */ + public MergeApiHttpResponse list( + OpportunitiesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities"); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOwnerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "owner_id", request.getOwnerId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_created_after", + request.getRemoteCreatedAfter().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getStageId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "stage_id", request.getStageId().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedOpportunityList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Opportunity object with the given values. + */ + public MergeApiHttpResponse create(OpportunityEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Opportunity object with the given values. + */ + public MergeApiHttpResponse create( + OpportunityEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), OpportunityResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Opportunity object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, OpportunitiesRetrieveRequest.builder().build()); + } + + /** + * Returns an Opportunity object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, OpportunitiesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Opportunity object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, OpportunitiesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Opportunity.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Updates an Opportunity object with the given id. + */ + public MergeApiHttpResponse partialUpdate( + String id, PatchedOpportunityEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates an Opportunity object with the given id. + */ + public MergeApiHttpResponse partialUpdate( + String id, PatchedOpportunityEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), OpportunityResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Opportunity PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Opportunity PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Opportunity POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Opportunity POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + OpportunitiesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + OpportunitiesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + OpportunitiesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/opportunities/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/opportunities/requests/OpportunitiesListRequest.java b/src/main/java/com/merge/api/resources/crm/opportunities/requests/OpportunitiesListRequest.java index c60a045c3..38263dad2 100644 --- a/src/main/java/com/merge/api/resources/crm/opportunities/requests/OpportunitiesListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/opportunities/requests/OpportunitiesListRequest.java @@ -12,10 +12,12 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.opportunities.types.OpportunitiesListRequestExpand; +import com.merge.api.resources.crm.opportunities.types.OpportunitiesListRequestExpandItem; import com.merge.api.resources.crm.opportunities.types.OpportunitiesListRequestStatus; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,6 +25,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = OpportunitiesListRequest.Builder.class) public final class OpportunitiesListRequest { + private final Optional> expand; + private final Optional accountId; private final Optional createdAfter; @@ -31,8 +35,6 @@ public final class OpportunitiesListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -64,11 +66,11 @@ public final class OpportunitiesListRequest { private final Map additionalProperties; private OpportunitiesListRequest( + Optional> expand, Optional accountId, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -84,11 +86,11 @@ private OpportunitiesListRequest( Optional stageId, Optional status, Map additionalProperties) { + this.expand = expand; this.accountId = accountId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -106,6 +108,14 @@ private OpportunitiesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return opportunities with this account. */ @@ -138,14 +148,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -275,11 +277,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(OpportunitiesListRequest other) { - return accountId.equals(other.accountId) + return expand.equals(other.expand) + && accountId.equals(other.accountId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -299,11 +301,11 @@ private boolean equalTo(OpportunitiesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.accountId, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -331,6 +333,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional accountId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -339,8 +343,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -375,11 +377,11 @@ public static final class Builder { private Builder() {} public Builder from(OpportunitiesListRequest other) { + expand(other.getExpand()); accountId(other.getAccountId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -397,6 +399,22 @@ public Builder from(OpportunitiesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(OpportunitiesListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "account_id", nulls = Nulls.SKIP) public Builder accountId(Optional accountId) { this.accountId = accountId; @@ -441,17 +459,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(OpportunitiesListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -608,11 +615,11 @@ public Builder status(OpportunitiesListRequestStatus status) { public OpportunitiesListRequest build() { return new OpportunitiesListRequest( + expand, accountId, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/crm/opportunities/requests/OpportunitiesRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/opportunities/requests/OpportunitiesRetrieveRequest.java index e1558e686..f9bcd2fc5 100644 --- a/src/main/java/com/merge/api/resources/crm/opportunities/requests/OpportunitiesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/opportunities/requests/OpportunitiesRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.opportunities.types.OpportunitiesRetrieveRequestExpand; +import com.merge.api.resources.crm.opportunities.types.OpportunitiesRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,12 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = OpportunitiesRetrieveRequest.Builder.class) public final class OpportunitiesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -34,15 +38,17 @@ public final class OpportunitiesRetrieveRequest { private final Map additionalProperties; private OpportunitiesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -52,7 +58,7 @@ private OpportunitiesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -72,6 +78,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -103,6 +117,7 @@ private boolean equalTo(OpportunitiesRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @@ -110,7 +125,12 @@ private boolean equalTo(OpportunitiesRetrieveRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.expand, this.includeRemoteData, this.includeRemoteFields, this.remoteFields, this.showEnumOrigins); + this.expand, + this.includeRemoteData, + this.includeRemoteFields, + this.includeShellData, + this.remoteFields, + this.showEnumOrigins); } @java.lang.Override @@ -124,12 +144,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -143,22 +165,28 @@ public Builder from(OpportunitiesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(OpportunitiesRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(OpportunitiesRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -181,6 +209,17 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -208,6 +247,7 @@ public OpportunitiesRetrieveRequest build() { expand, includeRemoteData, includeRemoteFields, + includeShellData, remoteFields, showEnumOrigins, additionalProperties); diff --git a/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesListRequestExpand.java b/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesListRequestExpand.java deleted file mode 100644 index 99c24d474..000000000 --- a/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesListRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.opportunities.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum OpportunitiesListRequestExpand { - ACCOUNT("account"), - - OWNER("owner"), - - OWNER_ACCOUNT("owner,account"), - - OWNER_STAGE("owner,stage"), - - OWNER_STAGE_ACCOUNT("owner,stage,account"), - - STAGE("stage"), - - STAGE_ACCOUNT("stage,account"); - - private final String value; - - OpportunitiesListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesListRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesListRequestExpandItem.java new file mode 100644 index 000000000..0f8523156 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesListRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.opportunities.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum OpportunitiesListRequestExpandItem { + ACCOUNT("account"), + + OWNER("owner"), + + STAGE("stage"); + + private final String value; + + OpportunitiesListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesRetrieveRequestExpand.java deleted file mode 100644 index 8fc257217..000000000 --- a/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesRetrieveRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.opportunities.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum OpportunitiesRetrieveRequestExpand { - ACCOUNT("account"), - - OWNER("owner"), - - OWNER_ACCOUNT("owner,account"), - - OWNER_STAGE("owner,stage"), - - OWNER_STAGE_ACCOUNT("owner,stage,account"), - - STAGE("stage"), - - STAGE_ACCOUNT("stage,account"); - - private final String value; - - OpportunitiesRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesRetrieveRequestExpandItem.java new file mode 100644 index 000000000..198e1a609 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/opportunities/types/OpportunitiesRetrieveRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.opportunities.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum OpportunitiesRetrieveRequestExpandItem { + ACCOUNT("account"), + + OWNER("owner"), + + STAGE("stage"); + + private final String value; + + OpportunitiesRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/passthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/crm/passthrough/AsyncPassthroughClient.java new file mode 100644 index 000000000..bdf3cd8a0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/passthrough/AsyncPassthroughClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.passthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.DataPassthroughRequest; +import com.merge.api.resources.crm.types.RemoteResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPassthroughClient rawClient; + + public AsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/passthrough/AsyncRawPassthroughClient.java b/src/main/java/com/merge/api/resources/crm/passthrough/AsyncRawPassthroughClient.java new file mode 100644 index 000000000..2e7e270ba --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/passthrough/AsyncRawPassthroughClient.java @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.DataPassthroughRequest; +import com.merge.api.resources.crm.types.RemoteResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/passthrough/PassthroughClient.java b/src/main/java/com/merge/api/resources/crm/passthrough/PassthroughClient.java index 568aae753..4890f304b 100644 --- a/src/main/java/com/merge/api/resources/crm/passthrough/PassthroughClient.java +++ b/src/main/java/com/merge/api/resources/crm/passthrough/PassthroughClient.java @@ -3,75 +3,39 @@ */ package com.merge.api.resources.crm.passthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.types.DataPassthroughRequest; import com.merge.api.resources.crm.types.RemoteResponse; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PassthroughClient { protected final ClientOptions clientOptions; + private final RawPassthroughClient rawClient; + public PassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPassthroughClient withRawResponse() { + return this.rawClient; } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/passthrough/RawPassthroughClient.java b/src/main/java/com/merge/api/resources/crm/passthrough/RawPassthroughClient.java new file mode 100644 index 000000000..c0c39328c --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/passthrough/RawPassthroughClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.DataPassthroughRequest; +import com.merge.api.resources.crm.types.RemoteResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPassthroughClient { + protected final ClientOptions clientOptions; + + public RawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/regeneratekey/AsyncRawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/crm/regeneratekey/AsyncRawRegenerateKeyClient.java new file mode 100644 index 000000000..5e32050d1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/regeneratekey/AsyncRawRegenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.crm.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/regeneratekey/AsyncRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/crm/regeneratekey/AsyncRegenerateKeyClient.java new file mode 100644 index 000000000..f65b52d02 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/regeneratekey/AsyncRegenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.regeneratekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.crm.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncRegenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawRegenerateKeyClient rawClient; + + public AsyncRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawRegenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/regeneratekey/RawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/crm/regeneratekey/RawRegenerateKeyClient.java new file mode 100644 index 000000000..7fab99504 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/regeneratekey/RawRegenerateKeyClient.java @@ -0,0 +1,82 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.crm.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/regeneratekey/RegenerateKeyClient.java b/src/main/java/com/merge/api/resources/crm/regeneratekey/RegenerateKeyClient.java index 539f5931f..509385896 100644 --- a/src/main/java/com/merge/api/resources/crm/regeneratekey/RegenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/crm/regeneratekey/RegenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.crm.regeneratekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.regeneratekey.requests.RemoteKeyForRegenerationRequest; import com.merge.api.resources.crm.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class RegenerateKeyClient { protected final ClientOptions clientOptions; + private final RawRegenerateKeyClient rawClient; + public RegenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawRegenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/regenerate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/scopes/AsyncRawScopesClient.java b/src/main/java/com/merge/api/resources/crm/scopes/AsyncRawScopesClient.java new file mode 100644 index 000000000..ecbec96dc --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/scopes/AsyncRawScopesClient.java @@ -0,0 +1,217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.crm.types.CommonModelScopeApi; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawScopesClient { + protected final ClientOptions clientOptions; + + public AsyncRawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/scopes/AsyncScopesClient.java b/src/main/java/com/merge/api/resources/crm/scopes/AsyncScopesClient.java new file mode 100644 index 000000000..97e06de9c --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/scopes/AsyncScopesClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.scopes; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.crm.types.CommonModelScopeApi; +import java.util.concurrent.CompletableFuture; + +public class AsyncScopesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawScopesClient rawClient; + + public AsyncScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawScopesClient withRawResponse() { + return this.rawClient; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve() { + return this.rawClient.defaultScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.defaultScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve() { + return this.rawClient.linkedAccountScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return this.rawClient.linkedAccountScopesCreate(request).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/scopes/RawScopesClient.java b/src/main/java/com/merge/api/resources/crm/scopes/RawScopesClient.java new file mode 100644 index 000000000..f187c5580 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/scopes/RawScopesClient.java @@ -0,0 +1,172 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.crm.types.CommonModelScopeApi; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawScopesClient { + protected final ClientOptions clientOptions; + + public RawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/scopes/ScopesClient.java b/src/main/java/com/merge/api/resources/crm/scopes/ScopesClient.java index 72e59d1d9..294d757fa 100644 --- a/src/main/java/com/merge/api/resources/crm/scopes/ScopesClient.java +++ b/src/main/java/com/merge/api/resources/crm/scopes/ScopesClient.java @@ -3,118 +3,61 @@ */ package com.merge.api.resources.crm.scopes; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; import com.merge.api.resources.crm.types.CommonModelScopeApi; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ScopesClient { protected final ClientOptions clientOptions; + private final RawScopesClient rawClient; + public ScopesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawScopesClient withRawResponse() { + return this.rawClient; } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve() { - return defaultScopesRetrieve(null); + return this.rawClient.defaultScopesRetrieve().body(); } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/default-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.defaultScopesRetrieve(requestOptions).body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve() { - return linkedAccountScopesRetrieve(null); + return this.rawClient.linkedAccountScopesRetrieve().body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/linked-account-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).body(); } /** * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more */ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelScopeDeserializerRequest request) { - return linkedAccountScopesCreate(request, null); + return this.rawClient.linkedAccountScopesCreate(request).body(); } /** @@ -122,40 +65,6 @@ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelSco */ public CommonModelScopeApi linkedAccountScopesCreate( LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/linked-account-scopes") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/stages/AsyncRawStagesClient.java b/src/main/java/com/merge/api/resources/crm/stages/AsyncRawStagesClient.java new file mode 100644 index 000000000..c9a8a5fc4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/stages/AsyncRawStagesClient.java @@ -0,0 +1,355 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.stages; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.stages.requests.StagesListRequest; +import com.merge.api.resources.crm.stages.requests.StagesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.stages.requests.StagesRetrieveRequest; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.crm.types.PaginatedStageList; +import com.merge.api.resources.crm.types.Stage; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawStagesClient { + protected final ClientOptions clientOptions; + + public AsyncRawStagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Stage objects. + */ + public CompletableFuture> list() { + return list(StagesListRequest.builder().build()); + } + + /** + * Returns a list of Stage objects. + */ + public CompletableFuture> list(StagesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Stage objects. + */ + public CompletableFuture> list( + StagesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/stages"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedStageList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Stage object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, StagesRetrieveRequest.builder().build()); + } + + /** + * Returns a Stage object with the given id. + */ + public CompletableFuture> retrieve(String id, StagesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Stage object with the given id. + */ + public CompletableFuture> retrieve( + String id, StagesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/stages") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Stage.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + StagesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + StagesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + StagesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/stages/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/stages/AsyncStagesClient.java b/src/main/java/com/merge/api/resources/crm/stages/AsyncStagesClient.java new file mode 100644 index 000000000..16b9c6a76 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/stages/AsyncStagesClient.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.stages; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.stages.requests.StagesListRequest; +import com.merge.api.resources.crm.stages.requests.StagesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.stages.requests.StagesRetrieveRequest; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.crm.types.PaginatedStageList; +import com.merge.api.resources.crm.types.Stage; +import java.util.concurrent.CompletableFuture; + +public class AsyncStagesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawStagesClient rawClient; + + public AsyncStagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawStagesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawStagesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Stage objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Stage objects. + */ + public CompletableFuture list(StagesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Stage objects. + */ + public CompletableFuture list(StagesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Stage object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Stage object with the given id. + */ + public CompletableFuture retrieve(String id, StagesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Stage object with the given id. + */ + public CompletableFuture retrieve(String id, StagesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + StagesRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + StagesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/stages/RawStagesClient.java b/src/main/java/com/merge/api/resources/crm/stages/RawStagesClient.java new file mode 100644 index 000000000..b3e1f3559 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/stages/RawStagesClient.java @@ -0,0 +1,309 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.stages; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.stages.requests.StagesListRequest; +import com.merge.api.resources.crm.stages.requests.StagesRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.stages.requests.StagesRetrieveRequest; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.crm.types.PaginatedStageList; +import com.merge.api.resources.crm.types.Stage; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawStagesClient { + protected final ClientOptions clientOptions; + + public RawStagesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Stage objects. + */ + public MergeApiHttpResponse list() { + return list(StagesListRequest.builder().build()); + } + + /** + * Returns a list of Stage objects. + */ + public MergeApiHttpResponse list(StagesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Stage objects. + */ + public MergeApiHttpResponse list(StagesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/stages"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedStageList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Stage object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, StagesRetrieveRequest.builder().build()); + } + + /** + * Returns a Stage object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, StagesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Stage object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, StagesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/stages") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Stage.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + StagesRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + StagesRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + StagesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/stages/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/stages/StagesClient.java b/src/main/java/com/merge/api/resources/crm/stages/StagesClient.java index 33eb9e634..8f56a27de 100644 --- a/src/main/java/com/merge/api/resources/crm/stages/StagesClient.java +++ b/src/main/java/com/merge/api/resources/crm/stages/StagesClient.java @@ -3,10 +3,7 @@ */ package com.merge.api.resources.crm.stages; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.stages.requests.StagesListRequest; import com.merge.api.resources.crm.stages.requests.StagesRemoteFieldClassesListRequest; @@ -14,181 +11,78 @@ import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; import com.merge.api.resources.crm.types.PaginatedStageList; import com.merge.api.resources.crm.types.Stage; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class StagesClient { protected final ClientOptions clientOptions; + private final RawStagesClient rawClient; + public StagesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawStagesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawStagesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Stage objects. */ public PaginatedStageList list() { - return list(StagesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Stage objects. */ public PaginatedStageList list(StagesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Stage objects. */ public PaginatedStageList list(StagesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/stages"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedStageList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Stage object with the given id. */ public Stage retrieve(String id) { - return retrieve(id, StagesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Stage object with the given id. */ public Stage retrieve(String id, StagesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Stage object with the given id. */ public Stage retrieve(String id, StagesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/stages") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Stage.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - StagesRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(StagesRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -196,61 +90,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(StagesRemoteFieldCla */ public PaginatedRemoteFieldClassList remoteFieldClassesList( StagesRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/stages/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/stages/requests/StagesRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/stages/requests/StagesRetrieveRequest.java index 58d02bedf..0a66316a6 100644 --- a/src/main/java/com/merge/api/resources/crm/stages/requests/StagesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/stages/requests/StagesRetrieveRequest.java @@ -24,14 +24,18 @@ public final class StagesRetrieveRequest { private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private StagesRetrieveRequest( Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -51,6 +55,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +76,13 @@ public Map getAdditionalProperties() { private boolean equalTo(StagesRetrieveRequest other) { return includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -87,6 +100,8 @@ public static final class Builder { private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,6 +110,7 @@ private Builder() {} public Builder from(StagesRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @@ -120,8 +136,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public StagesRetrieveRequest build() { - return new StagesRetrieveRequest(includeRemoteData, includeRemoteFields, additionalProperties); + return new StagesRetrieveRequest( + includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/syncstatus/AsyncRawSyncStatusClient.java b/src/main/java/com/merge/api/resources/crm/syncstatus/AsyncRawSyncStatusClient.java new file mode 100644 index 000000000..85f0a0765 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/syncstatus/AsyncRawSyncStatusClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.crm.types.PaginatedSyncStatusList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawSyncStatusClient { + protected final ClientOptions clientOptions; + + public AsyncRawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedSyncStatusList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/syncstatus/AsyncSyncStatusClient.java b/src/main/java/com/merge/api/resources/crm/syncstatus/AsyncSyncStatusClient.java new file mode 100644 index 000000000..6f3a371d5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/syncstatus/AsyncSyncStatusClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.syncstatus; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.crm.types.PaginatedSyncStatusList; +import java.util.concurrent.CompletableFuture; + +public class AsyncSyncStatusClient { + protected final ClientOptions clientOptions; + + private final AsyncRawSyncStatusClient rawClient; + + public AsyncSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawSyncStatusClient withRawResponse() { + return this.rawClient; + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list(SyncStatusListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list( + SyncStatusListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/syncstatus/RawSyncStatusClient.java b/src/main/java/com/merge/api/resources/crm/syncstatus/RawSyncStatusClient.java new file mode 100644 index 000000000..3e4faa933 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/syncstatus/RawSyncStatusClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.crm.types.PaginatedSyncStatusList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawSyncStatusClient { + protected final ClientOptions clientOptions; + + public RawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/syncstatus/SyncStatusClient.java b/src/main/java/com/merge/api/resources/crm/syncstatus/SyncStatusClient.java index 7082f55f6..1b88d8d52 100644 --- a/src/main/java/com/merge/api/resources/crm/syncstatus/SyncStatusClient.java +++ b/src/main/java/com/merge/api/resources/crm/syncstatus/SyncStatusClient.java @@ -3,78 +3,46 @@ */ package com.merge.api.resources.crm.syncstatus; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.syncstatus.requests.SyncStatusListRequest; import com.merge.api.resources.crm.types.PaginatedSyncStatusList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class SyncStatusClient { protected final ClientOptions clientOptions; + private final RawSyncStatusClient rawClient; + public SyncStatusClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawSyncStatusClient withRawResponse() { + return this.rawClient; } /** * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list() { - return list(SyncStatusListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/sync-status"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/tasks/AsyncRawTasksClient.java b/src/main/java/com/merge/api/resources/crm/tasks/AsyncRawTasksClient.java new file mode 100644 index 000000000..5bdcc262b --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/tasks/AsyncRawTasksClient.java @@ -0,0 +1,637 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.tasks; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.tasks.requests.PatchedTaskEndpointRequest; +import com.merge.api.resources.crm.tasks.requests.TaskEndpointRequest; +import com.merge.api.resources.crm.tasks.requests.TasksListRequest; +import com.merge.api.resources.crm.tasks.requests.TasksRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.tasks.requests.TasksRetrieveRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.crm.types.PaginatedTaskList; +import com.merge.api.resources.crm.types.Task; +import com.merge.api.resources.crm.types.TaskResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTasksClient { + protected final ClientOptions clientOptions; + + public AsyncRawTasksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Task objects. + */ + public CompletableFuture> list() { + return list(TasksListRequest.builder().build()); + } + + /** + * Returns a list of Task objects. + */ + public CompletableFuture> list(TasksListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Task objects. + */ + public CompletableFuture> list( + TasksListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTaskList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Task object with the given values. + */ + public CompletableFuture> create(TaskEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Task object with the given values. + */ + public CompletableFuture> create( + TaskEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TaskResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Task object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TasksRetrieveRequest.builder().build()); + } + + /** + * Returns a Task object with the given id. + */ + public CompletableFuture> retrieve(String id, TasksRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Task object with the given id. + */ + public CompletableFuture> retrieve( + String id, TasksRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Task.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Updates a Task object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedTaskEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates a Task object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedTaskEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TaskResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Task PATCHs. + */ + public CompletableFuture> metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Task PATCHs. + */ + public CompletableFuture> metaPatchRetrieve( + String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Task POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Task POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + TasksRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + TasksRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + TasksRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/tasks/AsyncTasksClient.java b/src/main/java/com/merge/api/resources/crm/tasks/AsyncTasksClient.java new file mode 100644 index 000000000..1009af4bb --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/tasks/AsyncTasksClient.java @@ -0,0 +1,158 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.tasks; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.tasks.requests.PatchedTaskEndpointRequest; +import com.merge.api.resources.crm.tasks.requests.TaskEndpointRequest; +import com.merge.api.resources.crm.tasks.requests.TasksListRequest; +import com.merge.api.resources.crm.tasks.requests.TasksRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.tasks.requests.TasksRetrieveRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.crm.types.PaginatedTaskList; +import com.merge.api.resources.crm.types.Task; +import com.merge.api.resources.crm.types.TaskResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncTasksClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTasksClient rawClient; + + public AsyncTasksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTasksClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTasksClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Task objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Task objects. + */ + public CompletableFuture list(TasksListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Task objects. + */ + public CompletableFuture list(TasksListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Task object with the given values. + */ + public CompletableFuture create(TaskEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Task object with the given values. + */ + public CompletableFuture create(TaskEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Task object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Task object with the given id. + */ + public CompletableFuture retrieve(String id, TasksRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Task object with the given id. + */ + public CompletableFuture retrieve(String id, TasksRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates a Task object with the given id. + */ + public CompletableFuture partialUpdate(String id, PatchedTaskEndpointRequest request) { + return this.rawClient.partialUpdate(id, request).thenApply(response -> response.body()); + } + + /** + * Updates a Task object with the given id. + */ + public CompletableFuture partialUpdate( + String id, PatchedTaskEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.partialUpdate(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Task PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id) { + return this.rawClient.metaPatchRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Task PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id, RequestOptions requestOptions) { + return this.rawClient.metaPatchRetrieve(id, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Task POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Task POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + TasksRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + TasksRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/tasks/RawTasksClient.java b/src/main/java/com/merge/api/resources/crm/tasks/RawTasksClient.java new file mode 100644 index 000000000..83aafed12 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/tasks/RawTasksClient.java @@ -0,0 +1,531 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.tasks; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.tasks.requests.PatchedTaskEndpointRequest; +import com.merge.api.resources.crm.tasks.requests.TaskEndpointRequest; +import com.merge.api.resources.crm.tasks.requests.TasksListRequest; +import com.merge.api.resources.crm.tasks.requests.TasksRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.tasks.requests.TasksRetrieveRequest; +import com.merge.api.resources.crm.types.MetaResponse; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.crm.types.PaginatedTaskList; +import com.merge.api.resources.crm.types.Task; +import com.merge.api.resources.crm.types.TaskResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTasksClient { + protected final ClientOptions clientOptions; + + public RawTasksClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Task objects. + */ + public MergeApiHttpResponse list() { + return list(TasksListRequest.builder().build()); + } + + /** + * Returns a list of Task objects. + */ + public MergeApiHttpResponse list(TasksListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Task objects. + */ + public MergeApiHttpResponse list(TasksListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTaskList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Task object with the given values. + */ + public MergeApiHttpResponse create(TaskEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Task object with the given values. + */ + public MergeApiHttpResponse create(TaskEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TaskResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Task object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TasksRetrieveRequest.builder().build()); + } + + /** + * Returns a Task object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TasksRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Task object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TasksRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Task.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Updates a Task object with the given id. + */ + public MergeApiHttpResponse partialUpdate(String id, PatchedTaskEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates a Task object with the given id. + */ + public MergeApiHttpResponse partialUpdate( + String id, PatchedTaskEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TaskResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Task PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Task PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Task POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Task POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + TasksRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + TasksRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + TasksRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/tasks/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/tasks/TasksClient.java b/src/main/java/com/merge/api/resources/crm/tasks/TasksClient.java index 6cf1f27ab..afb535b2f 100644 --- a/src/main/java/com/merge/api/resources/crm/tasks/TasksClient.java +++ b/src/main/java/com/merge/api/resources/crm/tasks/TasksClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.crm.tasks; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.tasks.requests.PatchedTaskEndpointRequest; import com.merge.api.resources.crm.tasks.requests.TaskEndpointRequest; @@ -19,386 +15,134 @@ import com.merge.api.resources.crm.types.PaginatedTaskList; import com.merge.api.resources.crm.types.Task; import com.merge.api.resources.crm.types.TaskResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TasksClient { protected final ClientOptions clientOptions; + private final RawTasksClient rawClient; + public TasksClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTasksClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTasksClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Task objects. */ public PaginatedTaskList list() { - return list(TasksListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Task objects. */ public PaginatedTaskList list(TasksListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Task objects. */ public PaginatedTaskList list(TasksListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/tasks"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTaskList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Task object with the given values. */ public TaskResponse create(TaskEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Task object with the given values. */ public TaskResponse create(TaskEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/tasks"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TaskResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Task object with the given id. */ public Task retrieve(String id) { - return retrieve(id, TasksRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Task object with the given id. */ public Task retrieve(String id, TasksRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Task object with the given id. */ public Task retrieve(String id, TasksRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/tasks") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Task.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Updates a Task object with the given id. */ public TaskResponse partialUpdate(String id, PatchedTaskEndpointRequest request) { - return partialUpdate(id, request, null); + return this.rawClient.partialUpdate(id, request).body(); } /** * Updates a Task object with the given id. */ public TaskResponse partialUpdate(String id, PatchedTaskEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/tasks") - .addPathSegment(id); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TaskResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.partialUpdate(id, request, requestOptions).body(); } /** * Returns metadata for Task PATCHs. */ public MetaResponse metaPatchRetrieve(String id) { - return metaPatchRetrieve(id, null); + return this.rawClient.metaPatchRetrieve(id).body(); } /** * Returns metadata for Task PATCHs. */ public MetaResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/tasks/meta/patch") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPatchRetrieve(id, requestOptions).body(); } /** * Returns metadata for Task POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Task POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/tasks/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - TasksRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(TasksRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -406,61 +150,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(TasksRemoteFieldClas */ public PaginatedRemoteFieldClassList remoteFieldClassesList( TasksRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/tasks/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/tasks/requests/TasksListRequest.java b/src/main/java/com/merge/api/resources/crm/tasks/requests/TasksListRequest.java index d9a7fc96d..ec71e473e 100644 --- a/src/main/java/com/merge/api/resources/crm/tasks/requests/TasksListRequest.java +++ b/src/main/java/com/merge/api/resources/crm/tasks/requests/TasksListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.tasks.types.TasksListRequestExpand; +import com.merge.api.resources.crm.tasks.types.TasksListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,14 +24,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TasksListRequest.Builder.class) public final class TasksListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -49,10 +51,10 @@ public final class TasksListRequest { private final Map additionalProperties; private TasksListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -62,10 +64,10 @@ private TasksListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -77,6 +79,14 @@ private TasksListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -101,14 +111,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -185,10 +187,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(TasksListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -202,10 +204,10 @@ private boolean equalTo(TasksListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -227,14 +229,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -257,10 +259,10 @@ public static final class Builder { private Builder() {} public Builder from(TasksListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -272,6 +274,22 @@ public Builder from(TasksListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(TasksListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -305,17 +323,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(TasksListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -406,10 +413,10 @@ public Builder remoteId(String remoteId) { public TasksListRequest build() { return new TasksListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/crm/tasks/requests/TasksRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/tasks/requests/TasksRetrieveRequest.java index 22c705fa9..eb8aa13ba 100644 --- a/src/main/java/com/merge/api/resources/crm/tasks/requests/TasksRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/tasks/requests/TasksRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.crm.tasks.types.TasksRetrieveRequestExpand; +import com.merge.api.resources.crm.tasks.types.TasksRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,22 +23,26 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TasksRetrieveRequest.Builder.class) public final class TasksRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private TasksRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -44,7 +50,7 @@ private TasksRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -64,6 +70,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -78,12 +92,13 @@ public Map getAdditionalProperties() { private boolean equalTo(TasksRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.expand, this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -97,12 +112,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -112,20 +129,26 @@ public Builder from(TasksRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(TasksRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(TasksRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -148,8 +171,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public TasksRetrieveRequest build() { - return new TasksRetrieveRequest(expand, includeRemoteData, includeRemoteFields, additionalProperties); + return new TasksRetrieveRequest( + expand, includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/tasks/types/TasksListRequestExpand.java b/src/main/java/com/merge/api/resources/crm/tasks/types/TasksListRequestExpand.java deleted file mode 100644 index 3a4905527..000000000 --- a/src/main/java/com/merge/api/resources/crm/tasks/types/TasksListRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.tasks.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TasksListRequestExpand { - ACCOUNT("account"), - - ACCOUNT_OPPORTUNITY("account,opportunity"), - - OPPORTUNITY("opportunity"), - - OWNER("owner"), - - OWNER_ACCOUNT("owner,account"), - - OWNER_ACCOUNT_OPPORTUNITY("owner,account,opportunity"), - - OWNER_OPPORTUNITY("owner,opportunity"); - - private final String value; - - TasksListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/tasks/types/TasksListRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/tasks/types/TasksListRequestExpandItem.java new file mode 100644 index 000000000..25ec63fa6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/tasks/types/TasksListRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.tasks.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TasksListRequestExpandItem { + ACCOUNT("account"), + + OPPORTUNITY("opportunity"), + + OWNER("owner"); + + private final String value; + + TasksListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/tasks/types/TasksRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/crm/tasks/types/TasksRetrieveRequestExpand.java deleted file mode 100644 index 5c828d586..000000000 --- a/src/main/java/com/merge/api/resources/crm/tasks/types/TasksRetrieveRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.tasks.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TasksRetrieveRequestExpand { - ACCOUNT("account"), - - ACCOUNT_OPPORTUNITY("account,opportunity"), - - OPPORTUNITY("opportunity"), - - OWNER("owner"), - - OWNER_ACCOUNT("owner,account"), - - OWNER_ACCOUNT_OPPORTUNITY("owner,account,opportunity"), - - OWNER_OPPORTUNITY("owner,opportunity"); - - private final String value; - - TasksRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/tasks/types/TasksRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/crm/tasks/types/TasksRetrieveRequestExpandItem.java new file mode 100644 index 000000000..750239ca3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/tasks/types/TasksRetrieveRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.tasks.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TasksRetrieveRequestExpandItem { + ACCOUNT("account"), + + OPPORTUNITY("opportunity"), + + OWNER("owner"); + + private final String value; + + TasksRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/types/AccountOwner.java b/src/main/java/com/merge/api/resources/crm/types/AccountOwner.java index 1fe54de3c..d73e04f53 100644 --- a/src/main/java/com/merge/api/resources/crm/types/AccountOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/AccountOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public AccountOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public AccountOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/AccountRequestOwner.java b/src/main/java/com/merge/api/resources/crm/types/AccountRequestOwner.java index ee85bde6b..e78fdb648 100644 --- a/src/main/java/com/merge/api/resources/crm/types/AccountRequestOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/AccountRequestOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public AccountRequestOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public AccountRequestOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/AccountToken.java b/src/main/java/com/merge/api/resources/crm/types/AccountToken.java index cbcddd0be..3ad9ef8bf 100644 --- a/src/main/java/com/merge/api/resources/crm/types/AccountToken.java +++ b/src/main/java/com/merge/api/resources/crm/types/AccountToken.java @@ -23,12 +23,15 @@ public final class AccountToken { private final AccountIntegration integration; + private final String id; + private final Map additionalProperties; private AccountToken( - String accountToken, AccountIntegration integration, Map additionalProperties) { + String accountToken, AccountIntegration integration, String id, Map additionalProperties) { this.accountToken = accountToken; this.integration = integration; + this.id = id; this.additionalProperties = additionalProperties; } @@ -42,6 +45,11 @@ public AccountIntegration getIntegration() { return integration; } + @JsonProperty("id") + public String getId() { + return id; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -54,12 +62,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(AccountToken other) { - return accountToken.equals(other.accountToken) && integration.equals(other.integration); + return accountToken.equals(other.accountToken) && integration.equals(other.integration) && id.equals(other.id); } @java.lang.Override public int hashCode() { - return Objects.hash(this.accountToken, this.integration); + return Objects.hash(this.accountToken, this.integration, this.id); } @java.lang.Override @@ -78,7 +86,11 @@ public interface AccountTokenStage { } public interface IntegrationStage { - _FinalStage integration(@NotNull AccountIntegration integration); + IdStage integration(@NotNull AccountIntegration integration); + } + + public interface IdStage { + _FinalStage id(@NotNull String id); } public interface _FinalStage { @@ -86,11 +98,13 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AccountTokenStage, IntegrationStage, _FinalStage { + public static final class Builder implements AccountTokenStage, IntegrationStage, IdStage, _FinalStage { private String accountToken; private AccountIntegration integration; + private String id; + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -100,6 +114,7 @@ private Builder() {} public Builder from(AccountToken other) { accountToken(other.getAccountToken()); integration(other.getIntegration()); + id(other.getId()); return this; } @@ -112,14 +127,21 @@ public IntegrationStage accountToken(@NotNull String accountToken) { @java.lang.Override @JsonSetter("integration") - public _FinalStage integration(@NotNull AccountIntegration integration) { + public IdStage integration(@NotNull AccountIntegration integration) { this.integration = integration; return this; } + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = id; + return this; + } + @java.lang.Override public AccountToken build() { - return new AccountToken(accountToken, integration, additionalProperties); + return new AccountToken(accountToken, integration, id, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/types/Address.java b/src/main/java/com/merge/api/resources/crm/types/Address.java index 98ddb49c8..2db26d8c4 100644 --- a/src/main/java/com/merge/api/resources/crm/types/Address.java +++ b/src/main/java/com/merge/api/resources/crm/types/Address.java @@ -35,9 +35,9 @@ public final class Address { private final Optional postalCode; - private final Optional country; + private final Optional country; - private final Optional addressType; + private final Optional addressType; private final Map additionalProperties; @@ -49,8 +49,8 @@ private Address( Optional city, Optional state, Optional postalCode, - Optional country, - Optional addressType, + Optional country, + Optional addressType, Map additionalProperties) { this.createdAt = createdAt; this.modifiedAt = modifiedAt; @@ -375,7 +375,7 @@ public Optional getPostalCode() { * */ @JsonProperty("country") - public Optional getCountry() { + public Optional getCountry() { return country; } @@ -387,7 +387,7 @@ public Optional getCountry() { * */ @JsonProperty("address_type") - public Optional getAddressType() { + public Optional getAddressType() { return addressType; } @@ -453,9 +453,9 @@ public static final class Builder { private Optional postalCode = Optional.empty(); - private Optional country = Optional.empty(); + private Optional country = Optional.empty(); - private Optional addressType = Optional.empty(); + private Optional addressType = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -553,23 +553,23 @@ public Builder postalCode(String postalCode) { } @JsonSetter(value = "country", nulls = Nulls.SKIP) - public Builder country(Optional country) { + public Builder country(Optional country) { this.country = country; return this; } - public Builder country(AddressCountry country) { + public Builder country(CountryEnum country) { this.country = Optional.ofNullable(country); return this; } @JsonSetter(value = "address_type", nulls = Nulls.SKIP) - public Builder addressType(Optional addressType) { + public Builder addressType(Optional addressType) { this.addressType = addressType; return this; } - public Builder addressType(AddressAddressType addressType) { + public Builder addressType(AddressTypeEnum addressType) { this.addressType = Optional.ofNullable(addressType); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/AddressAddressType.java b/src/main/java/com/merge/api/resources/crm/types/AddressAddressType.java deleted file mode 100644 index 1e4194254..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/AddressAddressType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AddressAddressType.Deserializer.class) -public final class AddressAddressType { - private final Object value; - - private final int type; - - private AddressAddressType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AddressTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddressAddressType && equalTo((AddressAddressType) other); - } - - private boolean equalTo(AddressAddressType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AddressAddressType of(AddressTypeEnum value) { - return new AddressAddressType(value, 0); - } - - public static AddressAddressType of(String value) { - return new AddressAddressType(value, 1); - } - - public interface Visitor { - T visit(AddressTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AddressAddressType.class); - } - - @java.lang.Override - public AddressAddressType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AddressTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/AddressCountry.java b/src/main/java/com/merge/api/resources/crm/types/AddressCountry.java deleted file mode 100644 index 5b2be98d1..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/AddressCountry.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AddressCountry.Deserializer.class) -public final class AddressCountry { - private final Object value; - - private final int type; - - private AddressCountry(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CountryEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddressCountry && equalTo((AddressCountry) other); - } - - private boolean equalTo(AddressCountry other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AddressCountry of(CountryEnum value) { - return new AddressCountry(value, 0); - } - - public static AddressCountry of(String value) { - return new AddressCountry(value, 1); - } - - public interface Visitor { - T visit(CountryEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AddressCountry.class); - } - - @java.lang.Override - public AddressCountry deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CountryEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/AddressRequest.java b/src/main/java/com/merge/api/resources/crm/types/AddressRequest.java index 3473fed69..c80e861c3 100644 --- a/src/main/java/com/merge/api/resources/crm/types/AddressRequest.java +++ b/src/main/java/com/merge/api/resources/crm/types/AddressRequest.java @@ -31,9 +31,9 @@ public final class AddressRequest { private final Optional postalCode; - private final Optional country; + private final Optional country; - private final Optional addressType; + private final Optional addressType; private final Optional> integrationParams; @@ -47,8 +47,8 @@ private AddressRequest( Optional city, Optional state, Optional postalCode, - Optional country, - Optional addressType, + Optional country, + Optional addressType, Optional> integrationParams, Optional> linkedAccountParams, Map additionalProperties) { @@ -359,7 +359,7 @@ public Optional getPostalCode() { * */ @JsonProperty("country") - public Optional getCountry() { + public Optional getCountry() { return country; } @@ -371,7 +371,7 @@ public Optional getCountry() { * */ @JsonProperty("address_type") - public Optional getAddressType() { + public Optional getAddressType() { return addressType; } @@ -443,9 +443,9 @@ public static final class Builder { private Optional postalCode = Optional.empty(); - private Optional country = Optional.empty(); + private Optional country = Optional.empty(); - private Optional addressType = Optional.empty(); + private Optional addressType = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -525,23 +525,23 @@ public Builder postalCode(String postalCode) { } @JsonSetter(value = "country", nulls = Nulls.SKIP) - public Builder country(Optional country) { + public Builder country(Optional country) { this.country = country; return this; } - public Builder country(AddressRequestCountry country) { + public Builder country(CountryEnum country) { this.country = Optional.ofNullable(country); return this; } @JsonSetter(value = "address_type", nulls = Nulls.SKIP) - public Builder addressType(Optional addressType) { + public Builder addressType(Optional addressType) { this.addressType = addressType; return this; } - public Builder addressType(AddressRequestAddressType addressType) { + public Builder addressType(AddressTypeEnum addressType) { this.addressType = Optional.ofNullable(addressType); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/AddressRequestAddressType.java b/src/main/java/com/merge/api/resources/crm/types/AddressRequestAddressType.java deleted file mode 100644 index 9af166933..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/AddressRequestAddressType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AddressRequestAddressType.Deserializer.class) -public final class AddressRequestAddressType { - private final Object value; - - private final int type; - - private AddressRequestAddressType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AddressTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddressRequestAddressType && equalTo((AddressRequestAddressType) other); - } - - private boolean equalTo(AddressRequestAddressType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AddressRequestAddressType of(AddressTypeEnum value) { - return new AddressRequestAddressType(value, 0); - } - - public static AddressRequestAddressType of(String value) { - return new AddressRequestAddressType(value, 1); - } - - public interface Visitor { - T visit(AddressTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AddressRequestAddressType.class); - } - - @java.lang.Override - public AddressRequestAddressType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AddressTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/AddressRequestCountry.java b/src/main/java/com/merge/api/resources/crm/types/AddressRequestCountry.java deleted file mode 100644 index 90ed1d278..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/AddressRequestCountry.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AddressRequestCountry.Deserializer.class) -public final class AddressRequestCountry { - private final Object value; - - private final int type; - - private AddressRequestCountry(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CountryEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddressRequestCountry && equalTo((AddressRequestCountry) other); - } - - private boolean equalTo(AddressRequestCountry other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AddressRequestCountry of(CountryEnum value) { - return new AddressRequestCountry(value, 0); - } - - public static AddressRequestCountry of(String value) { - return new AddressRequestCountry(value, 1); - } - - public interface Visitor { - T visit(CountryEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AddressRequestCountry.class); - } - - @java.lang.Override - public AddressRequestCountry deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CountryEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/AssociationAssociationType.java b/src/main/java/com/merge/api/resources/crm/types/AssociationAssociationType.java index d9cff0de5..a17b452f9 100644 --- a/src/main/java/com/merge/api/resources/crm/types/AssociationAssociationType.java +++ b/src/main/java/com/merge/api/resources/crm/types/AssociationAssociationType.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer displayName; - private final Optional cardinality; + private final Optional cardinality; private final Optional isRequired; @@ -54,7 +54,7 @@ private AssociationType( Optional> targetObjectClasses, Optional remoteKeyName, Optional displayName, - Optional cardinality, + Optional cardinality, Optional isRequired, Map additionalProperties) { this.id = id; @@ -123,7 +123,7 @@ public Optional getDisplayName() { } @JsonProperty("cardinality") - public Optional getCardinality() { + public Optional getCardinality() { return cardinality; } @@ -198,7 +198,7 @@ public static final class Builder { private Optional displayName = Optional.empty(); - private Optional cardinality = Optional.empty(); + private Optional cardinality = Optional.empty(); private Optional isRequired = Optional.empty(); @@ -310,12 +310,12 @@ public Builder displayName(String displayName) { } @JsonSetter(value = "cardinality", nulls = Nulls.SKIP) - public Builder cardinality(Optional cardinality) { + public Builder cardinality(Optional cardinality) { this.cardinality = cardinality; return this; } - public Builder cardinality(AssociationTypeCardinality cardinality) { + public Builder cardinality(CardinalityEnum cardinality) { this.cardinality = Optional.ofNullable(cardinality); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/AssociationTypeCardinality.java b/src/main/java/com/merge/api/resources/crm/types/AssociationTypeCardinality.java deleted file mode 100644 index 1f72efcff..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/AssociationTypeCardinality.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AssociationTypeCardinality.Deserializer.class) -public final class AssociationTypeCardinality { - private final Object value; - - private final int type; - - private AssociationTypeCardinality(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CardinalityEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AssociationTypeCardinality && equalTo((AssociationTypeCardinality) other); - } - - private boolean equalTo(AssociationTypeCardinality other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AssociationTypeCardinality of(CardinalityEnum value) { - return new AssociationTypeCardinality(value, 0); - } - - public static AssociationTypeCardinality of(String value) { - return new AssociationTypeCardinality(value, 1); - } - - public interface Visitor { - T visit(CardinalityEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AssociationTypeCardinality.class); - } - - @java.lang.Override - public AssociationTypeCardinality deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CardinalityEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/AuditLogEvent.java b/src/main/java/com/merge/api/resources/crm/types/AuditLogEvent.java index 0cb9917e9..5887e6fe3 100644 --- a/src/main/java/com/merge/api/resources/crm/types/AuditLogEvent.java +++ b/src/main/java/com/merge/api/resources/crm/types/AuditLogEvent.java @@ -28,11 +28,11 @@ public final class AuditLogEvent { private final Optional userEmail; - private final AuditLogEventRole role; + private final RoleEnum role; private final String ipAddress; - private final AuditLogEventEventType eventType; + private final EventTypeEnum eventType; private final String eventDescription; @@ -44,9 +44,9 @@ private AuditLogEvent( Optional id, Optional userName, Optional userEmail, - AuditLogEventRole role, + RoleEnum role, String ipAddress, - AuditLogEventEventType eventType, + EventTypeEnum eventType, String eventDescription, Optional createdAt, Map additionalProperties) { @@ -94,7 +94,7 @@ public Optional getUserEmail() { * */ @JsonProperty("role") - public AuditLogEventRole getRole() { + public RoleEnum getRole() { return role; } @@ -115,6 +115,7 @@ public String getIpAddress() { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -150,7 +151,7 @@ public String getIpAddress() { * */ @JsonProperty("event_type") - public AuditLogEventEventType getEventType() { + public EventTypeEnum getEventType() { return eventType; } @@ -209,7 +210,7 @@ public static RoleStage builder() { } public interface RoleStage { - IpAddressStage role(@NotNull AuditLogEventRole role); + IpAddressStage role(@NotNull RoleEnum role); Builder from(AuditLogEvent other); } @@ -219,7 +220,7 @@ public interface IpAddressStage { } public interface EventTypeStage { - EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType); + EventDescriptionStage eventType(@NotNull EventTypeEnum eventType); } public interface EventDescriptionStage { @@ -249,11 +250,11 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements RoleStage, IpAddressStage, EventTypeStage, EventDescriptionStage, _FinalStage { - private AuditLogEventRole role; + private RoleEnum role; private String ipAddress; - private AuditLogEventEventType eventType; + private EventTypeEnum eventType; private String eventDescription; @@ -297,7 +298,7 @@ public Builder from(AuditLogEvent other) { */ @java.lang.Override @JsonSetter("role") - public IpAddressStage role(@NotNull AuditLogEventRole role) { + public IpAddressStage role(@NotNull RoleEnum role) { this.role = role; return this; } @@ -321,6 +322,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -358,7 +360,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { */ @java.lang.Override @JsonSetter("event_type") - public EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType) { + public EventDescriptionStage eventType(@NotNull EventTypeEnum eventType) { this.eventType = eventType; return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/AuditLogEventEventType.java b/src/main/java/com/merge/api/resources/crm/types/AuditLogEventEventType.java deleted file mode 100644 index 2b4b02e8a..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/AuditLogEventEventType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventEventType.Deserializer.class) -public final class AuditLogEventEventType { - private final Object value; - - private final int type; - - private AuditLogEventEventType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EventTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventEventType && equalTo((AuditLogEventEventType) other); - } - - private boolean equalTo(AuditLogEventEventType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventEventType of(EventTypeEnum value) { - return new AuditLogEventEventType(value, 0); - } - - public static AuditLogEventEventType of(String value) { - return new AuditLogEventEventType(value, 1); - } - - public interface Visitor { - T visit(EventTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventEventType.class); - } - - @java.lang.Override - public AuditLogEventEventType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EventTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/AuditLogEventRole.java b/src/main/java/com/merge/api/resources/crm/types/AuditLogEventRole.java deleted file mode 100644 index d546d9e53..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/AuditLogEventRole.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventRole.Deserializer.class) -public final class AuditLogEventRole { - private final Object value; - - private final int type; - - private AuditLogEventRole(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RoleEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventRole && equalTo((AuditLogEventRole) other); - } - - private boolean equalTo(AuditLogEventRole other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventRole of(RoleEnum value) { - return new AuditLogEventRole(value, 0); - } - - public static AuditLogEventRole of(String value) { - return new AuditLogEventRole(value, 1); - } - - public interface Visitor { - T visit(RoleEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventRole.class); - } - - @java.lang.Override - public AuditLogEventRole deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RoleEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/ContactAccount.java b/src/main/java/com/merge/api/resources/crm/types/ContactAccount.java index 20db4fe89..1c18ebded 100644 --- a/src/main/java/com/merge/api/resources/crm/types/ContactAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/ContactAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ContactAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ContactAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/ContactOwner.java b/src/main/java/com/merge/api/resources/crm/types/ContactOwner.java index bf4dbe7da..37522a714 100644 --- a/src/main/java/com/merge/api/resources/crm/types/ContactOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/ContactOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ContactOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ContactOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/ContactRequestAccount.java b/src/main/java/com/merge/api/resources/crm/types/ContactRequestAccount.java index a70e7f6d1..f8f9461dc 100644 --- a/src/main/java/com/merge/api/resources/crm/types/ContactRequestAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/ContactRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ContactRequestAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ContactRequestAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/ContactRequestOwner.java b/src/main/java/com/merge/api/resources/crm/types/ContactRequestOwner.java index 6a8d20dbb..f1e96d956 100644 --- a/src/main/java/com/merge/api/resources/crm/types/ContactRequestOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/ContactRequestOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ContactRequestOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ContactRequestOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/Engagement.java b/src/main/java/com/merge/api/resources/crm/types/Engagement.java index 9f3e6429b..1439ce75b 100644 --- a/src/main/java/com/merge/api/resources/crm/types/Engagement.java +++ b/src/main/java/com/merge/api/resources/crm/types/Engagement.java @@ -37,7 +37,7 @@ public final class Engagement { private final Optional subject; - private final Optional direction; + private final Optional direction; private final Optional engagementType; @@ -67,7 +67,7 @@ private Engagement( Optional owner, Optional content, Optional subject, - Optional direction, + Optional direction, Optional engagementType, Optional startTime, Optional endTime, @@ -159,7 +159,7 @@ public Optional getSubject() { * */ @JsonProperty("direction") - public Optional getDirection() { + public Optional getDirection() { return direction; } @@ -301,7 +301,7 @@ public static final class Builder { private Optional subject = Optional.empty(); - private Optional direction = Optional.empty(); + private Optional direction = Optional.empty(); private Optional engagementType = Optional.empty(); @@ -425,12 +425,12 @@ public Builder subject(String subject) { } @JsonSetter(value = "direction", nulls = Nulls.SKIP) - public Builder direction(Optional direction) { + public Builder direction(Optional direction) { this.direction = direction; return this; } - public Builder direction(EngagementDirection direction) { + public Builder direction(DirectionEnum direction) { this.direction = Optional.ofNullable(direction); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/EngagementAccount.java b/src/main/java/com/merge/api/resources/crm/types/EngagementAccount.java index 299373100..35517c0d8 100644 --- a/src/main/java/com/merge/api/resources/crm/types/EngagementAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/EngagementAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EngagementAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EngagementAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/EngagementContactsItem.java b/src/main/java/com/merge/api/resources/crm/types/EngagementContactsItem.java index b1186833e..23952dd1d 100644 --- a/src/main/java/com/merge/api/resources/crm/types/EngagementContactsItem.java +++ b/src/main/java/com/merge/api/resources/crm/types/EngagementContactsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public EngagementContactsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EngagementContactsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/EngagementDirection.java b/src/main/java/com/merge/api/resources/crm/types/EngagementDirection.java deleted file mode 100644 index f1c199400..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/EngagementDirection.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EngagementDirection.Deserializer.class) -public final class EngagementDirection { - private final Object value; - - private final int type; - - private EngagementDirection(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((DirectionEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EngagementDirection && equalTo((EngagementDirection) other); - } - - private boolean equalTo(EngagementDirection other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EngagementDirection of(DirectionEnum value) { - return new EngagementDirection(value, 0); - } - - public static EngagementDirection of(String value) { - return new EngagementDirection(value, 1); - } - - public interface Visitor { - T visit(DirectionEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EngagementDirection.class); - } - - @java.lang.Override - public EngagementDirection deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, DirectionEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/EngagementEngagementType.java b/src/main/java/com/merge/api/resources/crm/types/EngagementEngagementType.java index 359909ca1..2fe364917 100644 --- a/src/main/java/com/merge/api/resources/crm/types/EngagementEngagementType.java +++ b/src/main/java/com/merge/api/resources/crm/types/EngagementEngagementType.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EngagementOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EngagementOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/EngagementRequest.java b/src/main/java/com/merge/api/resources/crm/types/EngagementRequest.java index dc757eaf1..57e6af5c5 100644 --- a/src/main/java/com/merge/api/resources/crm/types/EngagementRequest.java +++ b/src/main/java/com/merge/api/resources/crm/types/EngagementRequest.java @@ -29,7 +29,7 @@ public final class EngagementRequest { private final Optional subject; - private final Optional direction; + private final Optional direction; private final Optional engagementType; @@ -53,7 +53,7 @@ private EngagementRequest( Optional owner, Optional content, Optional subject, - Optional direction, + Optional direction, Optional engagementType, Optional startTime, Optional endTime, @@ -110,7 +110,7 @@ public Optional getSubject() { * */ @JsonProperty("direction") - public Optional getDirection() { + public Optional getDirection() { return direction; } @@ -226,7 +226,7 @@ public static final class Builder { private Optional subject = Optional.empty(); - private Optional direction = Optional.empty(); + private Optional direction = Optional.empty(); private Optional engagementType = Optional.empty(); @@ -299,12 +299,12 @@ public Builder subject(String subject) { } @JsonSetter(value = "direction", nulls = Nulls.SKIP) - public Builder direction(Optional direction) { + public Builder direction(Optional direction) { this.direction = direction; return this; } - public Builder direction(EngagementRequestDirection direction) { + public Builder direction(DirectionEnum direction) { this.direction = Optional.ofNullable(direction); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/EngagementRequestAccount.java b/src/main/java/com/merge/api/resources/crm/types/EngagementRequestAccount.java index 4d6115b0c..b94c21ba0 100644 --- a/src/main/java/com/merge/api/resources/crm/types/EngagementRequestAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/EngagementRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((DirectionEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EngagementRequestDirection && equalTo((EngagementRequestDirection) other); - } - - private boolean equalTo(EngagementRequestDirection other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EngagementRequestDirection of(DirectionEnum value) { - return new EngagementRequestDirection(value, 0); - } - - public static EngagementRequestDirection of(String value) { - return new EngagementRequestDirection(value, 1); - } - - public interface Visitor { - T visit(DirectionEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EngagementRequestDirection.class); - } - - @java.lang.Override - public EngagementRequestDirection deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, DirectionEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/EngagementRequestEngagementType.java b/src/main/java/com/merge/api/resources/crm/types/EngagementRequestEngagementType.java index 622e5ebcc..2117b4819 100644 --- a/src/main/java/com/merge/api/resources/crm/types/EngagementRequestEngagementType.java +++ b/src/main/java/com/merge/api/resources/crm/types/EngagementRequestEngagementType.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public EngagementRequestOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EngagementRequestOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/EngagementType.java b/src/main/java/com/merge/api/resources/crm/types/EngagementType.java index 730b41a99..13e5f7f62 100644 --- a/src/main/java/com/merge/api/resources/crm/types/EngagementType.java +++ b/src/main/java/com/merge/api/resources/crm/types/EngagementType.java @@ -30,7 +30,7 @@ public final class EngagementType { private final Optional modifiedAt; - private final Optional activityType; + private final Optional activityType; private final Optional name; @@ -43,7 +43,7 @@ private EngagementType( Optional remoteId, Optional createdAt, Optional modifiedAt, - Optional activityType, + Optional activityType, Optional name, Optional> remoteFields, Map additionalProperties) { @@ -95,7 +95,7 @@ public Optional getModifiedAt() { * */ @JsonProperty("activity_type") - public Optional getActivityType() { + public Optional getActivityType() { return activityType; } @@ -164,7 +164,7 @@ public static final class Builder { private Optional modifiedAt = Optional.empty(); - private Optional activityType = Optional.empty(); + private Optional activityType = Optional.empty(); private Optional name = Optional.empty(); @@ -231,12 +231,12 @@ public Builder modifiedAt(OffsetDateTime modifiedAt) { } @JsonSetter(value = "activity_type", nulls = Nulls.SKIP) - public Builder activityType(Optional activityType) { + public Builder activityType(Optional activityType) { this.activityType = activityType; return this; } - public Builder activityType(EngagementTypeActivityType activityType) { + public Builder activityType(ActivityTypeEnum activityType) { this.activityType = Optional.ofNullable(activityType); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/EngagementTypeActivityType.java b/src/main/java/com/merge/api/resources/crm/types/EngagementTypeActivityType.java deleted file mode 100644 index db87479f8..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/EngagementTypeActivityType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EngagementTypeActivityType.Deserializer.class) -public final class EngagementTypeActivityType { - private final Object value; - - private final int type; - - private EngagementTypeActivityType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ActivityTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EngagementTypeActivityType && equalTo((EngagementTypeActivityType) other); - } - - private boolean equalTo(EngagementTypeActivityType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EngagementTypeActivityType of(ActivityTypeEnum value) { - return new EngagementTypeActivityType(value, 0); - } - - public static EngagementTypeActivityType of(String value) { - return new EngagementTypeActivityType(value, 1); - } - - public interface Visitor { - T visit(ActivityTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EngagementTypeActivityType.class); - } - - @java.lang.Override - public EngagementTypeActivityType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ActivityTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/EventTypeEnum.java b/src/main/java/com/merge/api/resources/crm/types/EventTypeEnum.java index c1d32f29b..0c1f27e48 100644 --- a/src/main/java/com/merge/api/resources/crm/types/EventTypeEnum.java +++ b/src/main/java/com/merge/api/resources/crm/types/EventTypeEnum.java @@ -24,6 +24,8 @@ public enum EventTypeEnum { DELETED_LINKED_ACCOUNT("DELETED_LINKED_ACCOUNT"), + DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT("DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT"), + CREATED_DESTINATION("CREATED_DESTINATION"), DELETED_DESTINATION("DELETED_DESTINATION"), diff --git a/src/main/java/com/merge/api/resources/crm/types/Issue.java b/src/main/java/com/merge/api/resources/crm/types/Issue.java index 16b5c2b67..e81a75b1c 100644 --- a/src/main/java/com/merge/api/resources/crm/types/Issue.java +++ b/src/main/java/com/merge/api/resources/crm/types/Issue.java @@ -26,7 +26,7 @@ public final class Issue { private final Optional id; - private final Optional status; + private final Optional status; private final String errorDescription; @@ -44,7 +44,7 @@ public final class Issue { private Issue( Optional id, - Optional status, + Optional status, String errorDescription, Optional> endUser, Optional firstIncidentTime, @@ -76,7 +76,7 @@ public Optional getId() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -167,9 +167,9 @@ public interface _FinalStage { _FinalStage id(String id); - _FinalStage status(Optional status); + _FinalStage status(Optional status); - _FinalStage status(IssueStatus status); + _FinalStage status(IssueStatusEnum status); _FinalStage endUser(Optional> endUser); @@ -206,7 +206,7 @@ public static final class Builder implements ErrorDescriptionStage, _FinalStage private Optional> endUser = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional id = Optional.empty(); @@ -309,14 +309,14 @@ public _FinalStage endUser(Optional> endUser) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage status(IssueStatus status) { + public _FinalStage status(IssueStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @java.lang.Override @JsonSetter(value = "status", nulls = Nulls.SKIP) - public _FinalStage status(Optional status) { + public _FinalStage status(Optional status) { this.status = status; return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/IssueStatus.java b/src/main/java/com/merge/api/resources/crm/types/IssueStatus.java deleted file mode 100644 index 424a4317d..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/IssueStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = IssueStatus.Deserializer.class) -public final class IssueStatus { - private final Object value; - - private final int type; - - private IssueStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((IssueStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IssueStatus && equalTo((IssueStatus) other); - } - - private boolean equalTo(IssueStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static IssueStatus of(IssueStatusEnum value) { - return new IssueStatus(value, 0); - } - - public static IssueStatus of(String value) { - return new IssueStatus(value, 1); - } - - public interface Visitor { - T visit(IssueStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(IssueStatus.class); - } - - @java.lang.Override - public IssueStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, IssueStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/LastSyncResultEnum.java b/src/main/java/com/merge/api/resources/crm/types/LastSyncResultEnum.java new file mode 100644 index 000000000..455262876 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/types/LastSyncResultEnum.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum LastSyncResultEnum { + SYNCING("SYNCING"), + + DONE("DONE"), + + FAILED("FAILED"), + + DISABLED("DISABLED"), + + PAUSED("PAUSED"), + + PARTIALLY_SYNCED("PARTIALLY_SYNCED"); + + private final String value; + + LastSyncResultEnum(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/types/LeadConvertedAccount.java b/src/main/java/com/merge/api/resources/crm/types/LeadConvertedAccount.java index 07ace13e5..b91d8206f 100644 --- a/src/main/java/com/merge/api/resources/crm/types/LeadConvertedAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/LeadConvertedAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public LeadConvertedAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public LeadConvertedAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/LeadConvertedContact.java b/src/main/java/com/merge/api/resources/crm/types/LeadConvertedContact.java index 0d0db06e0..83d8720aa 100644 --- a/src/main/java/com/merge/api/resources/crm/types/LeadConvertedContact.java +++ b/src/main/java/com/merge/api/resources/crm/types/LeadConvertedContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public LeadConvertedContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public LeadConvertedContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/LeadOwner.java b/src/main/java/com/merge/api/resources/crm/types/LeadOwner.java index f8d9e0ccb..67cf9c28d 100644 --- a/src/main/java/com/merge/api/resources/crm/types/LeadOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/LeadOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public LeadOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public LeadOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/LeadRequestConvertedAccount.java b/src/main/java/com/merge/api/resources/crm/types/LeadRequestConvertedAccount.java index 86f2e4006..7d4ee3263 100644 --- a/src/main/java/com/merge/api/resources/crm/types/LeadRequestConvertedAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/LeadRequestConvertedAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public LeadRequestOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public LeadRequestOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/MultipartFormFieldRequest.java b/src/main/java/com/merge/api/resources/crm/types/MultipartFormFieldRequest.java index 185fc16ff..2c69a0c3c 100644 --- a/src/main/java/com/merge/api/resources/crm/types/MultipartFormFieldRequest.java +++ b/src/main/java/com/merge/api/resources/crm/types/MultipartFormFieldRequest.java @@ -25,7 +25,7 @@ public final class MultipartFormFieldRequest { private final String data; - private final Optional encoding; + private final Optional encoding; private final Optional fileName; @@ -36,7 +36,7 @@ public final class MultipartFormFieldRequest { private MultipartFormFieldRequest( String name, String data, - Optional encoding, + Optional encoding, Optional fileName, Optional contentType, Map additionalProperties) { @@ -73,7 +73,7 @@ public String getData() { * */ @JsonProperty("encoding") - public Optional getEncoding() { + public Optional getEncoding() { return encoding; } @@ -139,9 +139,9 @@ public interface DataStage { public interface _FinalStage { MultipartFormFieldRequest build(); - _FinalStage encoding(Optional encoding); + _FinalStage encoding(Optional encoding); - _FinalStage encoding(MultipartFormFieldRequestEncoding encoding); + _FinalStage encoding(EncodingEnum encoding); _FinalStage fileName(Optional fileName); @@ -162,7 +162,7 @@ public static final class Builder implements NameStage, DataStage, _FinalStage { private Optional fileName = Optional.empty(); - private Optional encoding = Optional.empty(); + private Optional encoding = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -245,14 +245,14 @@ public _FinalStage fileName(Optional fileName) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage encoding(MultipartFormFieldRequestEncoding encoding) { + public _FinalStage encoding(EncodingEnum encoding) { this.encoding = Optional.ofNullable(encoding); return this; } @java.lang.Override @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { + public _FinalStage encoding(Optional encoding) { this.encoding = encoding; return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/MultipartFormFieldRequestEncoding.java b/src/main/java/com/merge/api/resources/crm/types/MultipartFormFieldRequestEncoding.java deleted file mode 100644 index 881cf5df5..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/MultipartFormFieldRequestEncoding.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = MultipartFormFieldRequestEncoding.Deserializer.class) -public final class MultipartFormFieldRequestEncoding { - private final Object value; - - private final int type; - - private MultipartFormFieldRequestEncoding(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EncodingEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MultipartFormFieldRequestEncoding && equalTo((MultipartFormFieldRequestEncoding) other); - } - - private boolean equalTo(MultipartFormFieldRequestEncoding other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static MultipartFormFieldRequestEncoding of(EncodingEnum value) { - return new MultipartFormFieldRequestEncoding(value, 0); - } - - public static MultipartFormFieldRequestEncoding of(String value) { - return new MultipartFormFieldRequestEncoding(value, 1); - } - - public interface Visitor { - T visit(EncodingEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(MultipartFormFieldRequestEncoding.class); - } - - @java.lang.Override - public MultipartFormFieldRequestEncoding deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EncodingEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/NoteAccount.java b/src/main/java/com/merge/api/resources/crm/types/NoteAccount.java index f8055632c..9381f04a0 100644 --- a/src/main/java/com/merge/api/resources/crm/types/NoteAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/NoteAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public NoteAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public NoteAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/NoteContact.java b/src/main/java/com/merge/api/resources/crm/types/NoteContact.java index 50c803acc..9eca80ac4 100644 --- a/src/main/java/com/merge/api/resources/crm/types/NoteContact.java +++ b/src/main/java/com/merge/api/resources/crm/types/NoteContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public NoteContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public NoteContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/NoteOpportunity.java b/src/main/java/com/merge/api/resources/crm/types/NoteOpportunity.java index 33dc9c991..4481c7216 100644 --- a/src/main/java/com/merge/api/resources/crm/types/NoteOpportunity.java +++ b/src/main/java/com/merge/api/resources/crm/types/NoteOpportunity.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public NoteOpportunity deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public NoteOpportunity deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/NoteOwner.java b/src/main/java/com/merge/api/resources/crm/types/NoteOwner.java index 01a8cb680..3aed115ef 100644 --- a/src/main/java/com/merge/api/resources/crm/types/NoteOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/NoteOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public NoteOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public NoteOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/NoteRequestAccount.java b/src/main/java/com/merge/api/resources/crm/types/NoteRequestAccount.java index e8c47f152..acc4c9894 100644 --- a/src/main/java/com/merge/api/resources/crm/types/NoteRequestAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/NoteRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public NoteRequestAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public NoteRequestAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/NoteRequestContact.java b/src/main/java/com/merge/api/resources/crm/types/NoteRequestContact.java index 9d845f9e1..e8258b0b6 100644 --- a/src/main/java/com/merge/api/resources/crm/types/NoteRequestContact.java +++ b/src/main/java/com/merge/api/resources/crm/types/NoteRequestContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public NoteRequestContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public NoteRequestContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/NoteRequestOpportunity.java b/src/main/java/com/merge/api/resources/crm/types/NoteRequestOpportunity.java index 2dec23d28..2f3e9690a 100644 --- a/src/main/java/com/merge/api/resources/crm/types/NoteRequestOpportunity.java +++ b/src/main/java/com/merge/api/resources/crm/types/NoteRequestOpportunity.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public NoteRequestOpportunity deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public NoteRequestOpportunity deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/NoteRequestOwner.java b/src/main/java/com/merge/api/resources/crm/types/NoteRequestOwner.java index 9f8580f1d..35a3135bd 100644 --- a/src/main/java/com/merge/api/resources/crm/types/NoteRequestOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/NoteRequestOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public NoteRequestOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public NoteRequestOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/Opportunity.java b/src/main/java/com/merge/api/resources/crm/types/Opportunity.java index 71a6e2809..121bb7f18 100644 --- a/src/main/java/com/merge/api/resources/crm/types/Opportunity.java +++ b/src/main/java/com/merge/api/resources/crm/types/Opportunity.java @@ -43,7 +43,7 @@ public final class Opportunity { private final Optional stage; - private final Optional status; + private final Optional status; private final Optional lastActivityAt; @@ -72,7 +72,7 @@ private Opportunity( Optional owner, Optional account, Optional stage, - Optional status, + Optional status, Optional lastActivityAt, Optional closeDate, Optional remoteCreatedAt, @@ -188,7 +188,7 @@ public Optional getStage() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -325,7 +325,7 @@ public static final class Builder { private Optional stage = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional lastActivityAt = Optional.empty(); @@ -479,12 +479,12 @@ public Builder stage(OpportunityStage stage) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(OpportunityStatus status) { + public Builder status(OpportunityStatusEnum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/OpportunityAccount.java b/src/main/java/com/merge/api/resources/crm/types/OpportunityAccount.java index c0712cc25..0f8287678 100644 --- a/src/main/java/com/merge/api/resources/crm/types/OpportunityAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/OpportunityAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public OpportunityAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public OpportunityAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/OpportunityOwner.java b/src/main/java/com/merge/api/resources/crm/types/OpportunityOwner.java index 21e499ad5..291b4d0df 100644 --- a/src/main/java/com/merge/api/resources/crm/types/OpportunityOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/OpportunityOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public OpportunityOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public OpportunityOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/OpportunityRequest.java b/src/main/java/com/merge/api/resources/crm/types/OpportunityRequest.java index c2bced6f1..010c17d9a 100644 --- a/src/main/java/com/merge/api/resources/crm/types/OpportunityRequest.java +++ b/src/main/java/com/merge/api/resources/crm/types/OpportunityRequest.java @@ -35,7 +35,7 @@ public final class OpportunityRequest { private final Optional stage; - private final Optional status; + private final Optional status; private final Optional lastActivityAt; @@ -56,7 +56,7 @@ private OpportunityRequest( Optional owner, Optional account, Optional stage, - Optional status, + Optional status, Optional lastActivityAt, Optional closeDate, Optional> integrationParams, @@ -135,7 +135,7 @@ public Optional getStage() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -236,7 +236,7 @@ public static final class Builder { private Optional stage = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional lastActivityAt = Optional.empty(); @@ -336,12 +336,12 @@ public Builder stage(OpportunityRequestStage stage) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(OpportunityRequestStatus status) { + public Builder status(OpportunityStatusEnum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestAccount.java b/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestAccount.java index 7b8fe838f..f5df00f52 100644 --- a/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public OpportunityRequestOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public OpportunityRequestOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestStage.java b/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestStage.java index cdf6f0cf2..4d12768bb 100644 --- a/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestStage.java +++ b/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestStage.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public OpportunityRequestStage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public OpportunityRequestStage deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestStatus.java b/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestStatus.java deleted file mode 100644 index 31dc44cb9..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/OpportunityRequestStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = OpportunityRequestStatus.Deserializer.class) -public final class OpportunityRequestStatus { - private final Object value; - - private final int type; - - private OpportunityRequestStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((OpportunityStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof OpportunityRequestStatus && equalTo((OpportunityRequestStatus) other); - } - - private boolean equalTo(OpportunityRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static OpportunityRequestStatus of(OpportunityStatusEnum value) { - return new OpportunityRequestStatus(value, 0); - } - - public static OpportunityRequestStatus of(String value) { - return new OpportunityRequestStatus(value, 1); - } - - public interface Visitor { - T visit(OpportunityStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(OpportunityRequestStatus.class); - } - - @java.lang.Override - public OpportunityRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, OpportunityStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/OpportunityStage.java b/src/main/java/com/merge/api/resources/crm/types/OpportunityStage.java index 4228a322c..51400f835 100644 --- a/src/main/java/com/merge/api/resources/crm/types/OpportunityStage.java +++ b/src/main/java/com/merge/api/resources/crm/types/OpportunityStage.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public OpportunityStage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public OpportunityStage deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/OpportunityStatus.java b/src/main/java/com/merge/api/resources/crm/types/OpportunityStatus.java deleted file mode 100644 index 53baf9d0f..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/OpportunityStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = OpportunityStatus.Deserializer.class) -public final class OpportunityStatus { - private final Object value; - - private final int type; - - private OpportunityStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((OpportunityStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof OpportunityStatus && equalTo((OpportunityStatus) other); - } - - private boolean equalTo(OpportunityStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static OpportunityStatus of(OpportunityStatusEnum value) { - return new OpportunityStatus(value, 0); - } - - public static OpportunityStatus of(String value) { - return new OpportunityStatus(value, 1); - } - - public interface Visitor { - T visit(OpportunityStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(OpportunityStatus.class); - } - - @java.lang.Override - public OpportunityStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, OpportunityStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/PatchedContactRequestOwner.java b/src/main/java/com/merge/api/resources/crm/types/PatchedContactRequestOwner.java index 7cb7088f7..5065805c0 100644 --- a/src/main/java/com/merge/api/resources/crm/types/PatchedContactRequestOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/PatchedContactRequestOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer subject; - private final Optional direction; + private final Optional direction; private final Optional engagementType; @@ -53,7 +53,7 @@ private PatchedEngagementRequest( Optional owner, Optional content, Optional subject, - Optional direction, + Optional direction, Optional engagementType, Optional startTime, Optional endTime, @@ -110,7 +110,7 @@ public Optional getSubject() { * */ @JsonProperty("direction") - public Optional getDirection() { + public Optional getDirection() { return direction; } @@ -226,7 +226,7 @@ public static final class Builder { private Optional subject = Optional.empty(); - private Optional direction = Optional.empty(); + private Optional direction = Optional.empty(); private Optional engagementType = Optional.empty(); @@ -299,12 +299,12 @@ public Builder subject(String subject) { } @JsonSetter(value = "direction", nulls = Nulls.SKIP) - public Builder direction(Optional direction) { + public Builder direction(Optional direction) { this.direction = direction; return this; } - public Builder direction(PatchedEngagementRequestDirection direction) { + public Builder direction(DirectionEnum direction) { this.direction = Optional.ofNullable(direction); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/PatchedEngagementRequestDirection.java b/src/main/java/com/merge/api/resources/crm/types/PatchedEngagementRequestDirection.java deleted file mode 100644 index 32f376483..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/PatchedEngagementRequestDirection.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PatchedEngagementRequestDirection.Deserializer.class) -public final class PatchedEngagementRequestDirection { - private final Object value; - - private final int type; - - private PatchedEngagementRequestDirection(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((DirectionEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PatchedEngagementRequestDirection && equalTo((PatchedEngagementRequestDirection) other); - } - - private boolean equalTo(PatchedEngagementRequestDirection other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PatchedEngagementRequestDirection of(DirectionEnum value) { - return new PatchedEngagementRequestDirection(value, 0); - } - - public static PatchedEngagementRequestDirection of(String value) { - return new PatchedEngagementRequestDirection(value, 1); - } - - public interface Visitor { - T visit(DirectionEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PatchedEngagementRequestDirection.class); - } - - @java.lang.Override - public PatchedEngagementRequestDirection deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, DirectionEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/PatchedOpportunityRequest.java b/src/main/java/com/merge/api/resources/crm/types/PatchedOpportunityRequest.java index 5a03c865e..fb5c0e7c8 100644 --- a/src/main/java/com/merge/api/resources/crm/types/PatchedOpportunityRequest.java +++ b/src/main/java/com/merge/api/resources/crm/types/PatchedOpportunityRequest.java @@ -35,7 +35,7 @@ public final class PatchedOpportunityRequest { private final Optional stage; - private final Optional status; + private final Optional status; private final Optional lastActivityAt; @@ -56,7 +56,7 @@ private PatchedOpportunityRequest( Optional owner, Optional account, Optional stage, - Optional status, + Optional status, Optional lastActivityAt, Optional closeDate, Optional> integrationParams, @@ -135,7 +135,7 @@ public Optional getStage() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -236,7 +236,7 @@ public static final class Builder { private Optional stage = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional lastActivityAt = Optional.empty(); @@ -336,12 +336,12 @@ public Builder stage(String stage) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(PatchedOpportunityRequestStatus status) { + public Builder status(OpportunityStatusEnum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/PatchedOpportunityRequestStatus.java b/src/main/java/com/merge/api/resources/crm/types/PatchedOpportunityRequestStatus.java deleted file mode 100644 index 727989830..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/PatchedOpportunityRequestStatus.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PatchedOpportunityRequestStatus.Deserializer.class) -public final class PatchedOpportunityRequestStatus { - private final Object value; - - private final int type; - - private PatchedOpportunityRequestStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((OpportunityStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PatchedOpportunityRequestStatus && equalTo((PatchedOpportunityRequestStatus) other); - } - - private boolean equalTo(PatchedOpportunityRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PatchedOpportunityRequestStatus of(OpportunityStatusEnum value) { - return new PatchedOpportunityRequestStatus(value, 0); - } - - public static PatchedOpportunityRequestStatus of(String value) { - return new PatchedOpportunityRequestStatus(value, 1); - } - - public interface Visitor { - T visit(OpportunityStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PatchedOpportunityRequestStatus.class); - } - - @java.lang.Override - public PatchedOpportunityRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, OpportunityStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/PatchedTaskRequest.java b/src/main/java/com/merge/api/resources/crm/types/PatchedTaskRequest.java index c7f75e730..d187d046e 100644 --- a/src/main/java/com/merge/api/resources/crm/types/PatchedTaskRequest.java +++ b/src/main/java/com/merge/api/resources/crm/types/PatchedTaskRequest.java @@ -37,7 +37,7 @@ public final class PatchedTaskRequest { private final Optional dueDate; - private final Optional status; + private final Optional status; private final Optional> integrationParams; @@ -55,7 +55,7 @@ private PatchedTaskRequest( Optional opportunity, Optional completedDate, Optional dueDate, - Optional status, + Optional status, Optional> integrationParams, Optional> linkedAccountParams, Optional> remoteFields, @@ -138,7 +138,7 @@ public Optional getDueDate() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -223,7 +223,7 @@ public static final class Builder { private Optional dueDate = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -329,12 +329,12 @@ public Builder dueDate(OffsetDateTime dueDate) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(PatchedTaskRequestStatus status) { + public Builder status(TaskStatusEnum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/PatchedTaskRequestStatus.java b/src/main/java/com/merge/api/resources/crm/types/PatchedTaskRequestStatus.java deleted file mode 100644 index 7318729f4..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/PatchedTaskRequestStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PatchedTaskRequestStatus.Deserializer.class) -public final class PatchedTaskRequestStatus { - private final Object value; - - private final int type; - - private PatchedTaskRequestStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TaskStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PatchedTaskRequestStatus && equalTo((PatchedTaskRequestStatus) other); - } - - private boolean equalTo(PatchedTaskRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PatchedTaskRequestStatus of(TaskStatusEnum value) { - return new PatchedTaskRequestStatus(value, 0); - } - - public static PatchedTaskRequestStatus of(String value) { - return new PatchedTaskRequestStatus(value, 1); - } - - public interface Visitor { - T visit(TaskStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PatchedTaskRequestStatus.class); - } - - @java.lang.Override - public PatchedTaskRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TaskStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldApiCoverage.java b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldApiCoverage.java index 4c4674fb3..4e05bd259 100644 --- a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldApiCoverage.java +++ b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldApiCoverage.java @@ -28,6 +28,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((int) this.value); @@ -77,7 +78,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); if (value instanceof Integer) { return of((Integer) value); diff --git a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClass.java b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClass.java index 41cf8c49a..9473a5cee 100644 --- a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClass.java +++ b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClass.java @@ -33,9 +33,9 @@ public final class RemoteFieldClass { private final Optional isRequired; - private final Optional fieldType; + private final Optional fieldType; - private final Optional fieldFormat; + private final Optional fieldFormat; private final Optional> fieldChoices; @@ -50,8 +50,8 @@ private RemoteFieldClass( Optional description, Optional isCustom, Optional isRequired, - Optional fieldType, - Optional fieldFormat, + Optional fieldType, + Optional fieldFormat, Optional> fieldChoices, Optional itemSchema, Map additionalProperties) { @@ -99,12 +99,12 @@ public Optional getIsRequired() { } @JsonProperty("field_type") - public Optional getFieldType() { + public Optional getFieldType() { return fieldType; } @JsonProperty("field_format") - public Optional getFieldFormat() { + public Optional getFieldFormat() { return fieldFormat; } @@ -180,9 +180,9 @@ public static final class Builder { private Optional isRequired = Optional.empty(); - private Optional fieldType = Optional.empty(); + private Optional fieldType = Optional.empty(); - private Optional fieldFormat = Optional.empty(); + private Optional fieldFormat = Optional.empty(); private Optional> fieldChoices = Optional.empty(); @@ -274,23 +274,23 @@ public Builder isRequired(Boolean isRequired) { } @JsonSetter(value = "field_type", nulls = Nulls.SKIP) - public Builder fieldType(Optional fieldType) { + public Builder fieldType(Optional fieldType) { this.fieldType = fieldType; return this; } - public Builder fieldType(RemoteFieldClassFieldType fieldType) { + public Builder fieldType(FieldTypeEnum fieldType) { this.fieldType = Optional.ofNullable(fieldType); return this; } @JsonSetter(value = "field_format", nulls = Nulls.SKIP) - public Builder fieldFormat(Optional fieldFormat) { + public Builder fieldFormat(Optional fieldFormat) { this.fieldFormat = fieldFormat; return this; } - public Builder fieldFormat(RemoteFieldClassFieldFormat fieldFormat) { + public Builder fieldFormat(FieldFormatEnum fieldFormat) { this.fieldFormat = Optional.ofNullable(fieldFormat); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassFieldFormat.java b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassFieldFormat.java deleted file mode 100644 index 839923ee2..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassFieldFormat.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RemoteFieldClassFieldFormat.Deserializer.class) -public final class RemoteFieldClassFieldFormat { - private final Object value; - - private final int type; - - private RemoteFieldClassFieldFormat(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((FieldFormatEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RemoteFieldClassFieldFormat && equalTo((RemoteFieldClassFieldFormat) other); - } - - private boolean equalTo(RemoteFieldClassFieldFormat other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RemoteFieldClassFieldFormat of(FieldFormatEnum value) { - return new RemoteFieldClassFieldFormat(value, 0); - } - - public static RemoteFieldClassFieldFormat of(String value) { - return new RemoteFieldClassFieldFormat(value, 1); - } - - public interface Visitor { - T visit(FieldFormatEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RemoteFieldClassFieldFormat.class); - } - - @java.lang.Override - public RemoteFieldClassFieldFormat deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FieldFormatEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassFieldType.java b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassFieldType.java deleted file mode 100644 index c586ca306..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassFieldType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RemoteFieldClassFieldType.Deserializer.class) -public final class RemoteFieldClassFieldType { - private final Object value; - - private final int type; - - private RemoteFieldClassFieldType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((FieldTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RemoteFieldClassFieldType && equalTo((RemoteFieldClassFieldType) other); - } - - private boolean equalTo(RemoteFieldClassFieldType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RemoteFieldClassFieldType of(FieldTypeEnum value) { - return new RemoteFieldClassFieldType(value, 0); - } - - public static RemoteFieldClassFieldType of(String value) { - return new RemoteFieldClassFieldType(value, 1); - } - - public interface Visitor { - T visit(FieldTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RemoteFieldClassFieldType.class); - } - - @java.lang.Override - public RemoteFieldClassFieldType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FieldTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassForCustomObjectClass.java b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassForCustomObjectClass.java index 095ef21d3..0196212cf 100644 --- a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassForCustomObjectClass.java +++ b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassForCustomObjectClass.java @@ -34,9 +34,9 @@ public final class RemoteFieldClassForCustomObjectClass { private final Optional isRequired; - private final Optional fieldType; + private final Optional fieldType; - private final Optional fieldFormat; + private final Optional fieldFormat; private final Optional> fieldChoices; @@ -51,8 +51,8 @@ private RemoteFieldClassForCustomObjectClass( Optional remoteKeyName, Optional description, Optional isRequired, - Optional fieldType, - Optional fieldFormat, + Optional fieldType, + Optional fieldFormat, Optional> fieldChoices, Optional itemSchema, Map additionalProperties) { @@ -106,12 +106,12 @@ public Optional getIsRequired() { } @JsonProperty("field_type") - public Optional getFieldType() { + public Optional getFieldType() { return fieldType; } @JsonProperty("field_format") - public Optional getFieldFormat() { + public Optional getFieldFormat() { return fieldFormat; } @@ -188,9 +188,9 @@ public static final class Builder { private Optional isRequired = Optional.empty(); - private Optional fieldType = Optional.empty(); + private Optional fieldType = Optional.empty(); - private Optional fieldFormat = Optional.empty(); + private Optional fieldFormat = Optional.empty(); private Optional> fieldChoices = Optional.empty(); @@ -282,23 +282,23 @@ public Builder isRequired(Boolean isRequired) { } @JsonSetter(value = "field_type", nulls = Nulls.SKIP) - public Builder fieldType(Optional fieldType) { + public Builder fieldType(Optional fieldType) { this.fieldType = fieldType; return this; } - public Builder fieldType(RemoteFieldClassForCustomObjectClassFieldType fieldType) { + public Builder fieldType(FieldTypeEnum fieldType) { this.fieldType = Optional.ofNullable(fieldType); return this; } @JsonSetter(value = "field_format", nulls = Nulls.SKIP) - public Builder fieldFormat(Optional fieldFormat) { + public Builder fieldFormat(Optional fieldFormat) { this.fieldFormat = fieldFormat; return this; } - public Builder fieldFormat(RemoteFieldClassForCustomObjectClassFieldFormat fieldFormat) { + public Builder fieldFormat(FieldFormatEnum fieldFormat) { this.fieldFormat = Optional.ofNullable(fieldFormat); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassForCustomObjectClassFieldFormat.java b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassForCustomObjectClassFieldFormat.java deleted file mode 100644 index e1f456a83..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassForCustomObjectClassFieldFormat.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RemoteFieldClassForCustomObjectClassFieldFormat.Deserializer.class) -public final class RemoteFieldClassForCustomObjectClassFieldFormat { - private final Object value; - - private final int type; - - private RemoteFieldClassForCustomObjectClassFieldFormat(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((FieldFormatEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RemoteFieldClassForCustomObjectClassFieldFormat - && equalTo((RemoteFieldClassForCustomObjectClassFieldFormat) other); - } - - private boolean equalTo(RemoteFieldClassForCustomObjectClassFieldFormat other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RemoteFieldClassForCustomObjectClassFieldFormat of(FieldFormatEnum value) { - return new RemoteFieldClassForCustomObjectClassFieldFormat(value, 0); - } - - public static RemoteFieldClassForCustomObjectClassFieldFormat of(String value) { - return new RemoteFieldClassForCustomObjectClassFieldFormat(value, 1); - } - - public interface Visitor { - T visit(FieldFormatEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RemoteFieldClassForCustomObjectClassFieldFormat.class); - } - - @java.lang.Override - public RemoteFieldClassForCustomObjectClassFieldFormat deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FieldFormatEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassForCustomObjectClassFieldType.java b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassForCustomObjectClassFieldType.java deleted file mode 100644 index e1ec8e80b..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldClassForCustomObjectClassFieldType.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RemoteFieldClassForCustomObjectClassFieldType.Deserializer.class) -public final class RemoteFieldClassForCustomObjectClassFieldType { - private final Object value; - - private final int type; - - private RemoteFieldClassForCustomObjectClassFieldType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((FieldTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RemoteFieldClassForCustomObjectClassFieldType - && equalTo((RemoteFieldClassForCustomObjectClassFieldType) other); - } - - private boolean equalTo(RemoteFieldClassForCustomObjectClassFieldType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RemoteFieldClassForCustomObjectClassFieldType of(FieldTypeEnum value) { - return new RemoteFieldClassForCustomObjectClassFieldType(value, 0); - } - - public static RemoteFieldClassForCustomObjectClassFieldType of(String value) { - return new RemoteFieldClassForCustomObjectClassFieldType(value, 1); - } - - public interface Visitor { - T visit(FieldTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RemoteFieldClassForCustomObjectClassFieldType.class); - } - - @java.lang.Override - public RemoteFieldClassForCustomObjectClassFieldType deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FieldTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldRemoteFieldClass.java b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldRemoteFieldClass.java index a838b4702..a34e38cb2 100644 --- a/src/main/java/com/merge/api/resources/crm/types/RemoteFieldRemoteFieldClass.java +++ b/src/main/java/com/merge/api/resources/crm/types/RemoteFieldRemoteFieldClass.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer nextSyncStart; - private final SyncStatusStatusEnum status; + private final Optional lastSyncResult; + + private final Optional lastSyncFinished; + + private final StatusFd5Enum status; private final boolean isInitialSync; @@ -43,7 +47,9 @@ private SyncStatus( String modelId, Optional lastSyncStart, Optional nextSyncStart, - SyncStatusStatusEnum status, + Optional lastSyncResult, + Optional lastSyncFinished, + StatusFd5Enum status, boolean isInitialSync, Optional selectiveSyncConfigurationsUsage, Map additionalProperties) { @@ -51,6 +57,8 @@ private SyncStatus( this.modelId = modelId; this.lastSyncStart = lastSyncStart; this.nextSyncStart = nextSyncStart; + this.lastSyncResult = lastSyncResult; + this.lastSyncFinished = lastSyncFinished; this.status = status; this.isInitialSync = isInitialSync; this.selectiveSyncConfigurationsUsage = selectiveSyncConfigurationsUsage; @@ -77,8 +85,18 @@ public Optional getNextSyncStart() { return nextSyncStart; } + @JsonProperty("last_sync_result") + public Optional getLastSyncResult() { + return lastSyncResult; + } + + @JsonProperty("last_sync_finished") + public Optional getLastSyncFinished() { + return lastSyncFinished; + } + @JsonProperty("status") - public SyncStatusStatusEnum getStatus() { + public StatusFd5Enum getStatus() { return status; } @@ -108,6 +126,8 @@ private boolean equalTo(SyncStatus other) { && modelId.equals(other.modelId) && lastSyncStart.equals(other.lastSyncStart) && nextSyncStart.equals(other.nextSyncStart) + && lastSyncResult.equals(other.lastSyncResult) + && lastSyncFinished.equals(other.lastSyncFinished) && status.equals(other.status) && isInitialSync == other.isInitialSync && selectiveSyncConfigurationsUsage.equals(other.selectiveSyncConfigurationsUsage); @@ -120,6 +140,8 @@ public int hashCode() { this.modelId, this.lastSyncStart, this.nextSyncStart, + this.lastSyncResult, + this.lastSyncFinished, this.status, this.isInitialSync, this.selectiveSyncConfigurationsUsage); @@ -145,7 +167,7 @@ public interface ModelIdStage { } public interface StatusStage { - IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status); + IsInitialSyncStage status(@NotNull StatusFd5Enum status); } public interface IsInitialSyncStage { @@ -163,6 +185,14 @@ public interface _FinalStage { _FinalStage nextSyncStart(OffsetDateTime nextSyncStart); + _FinalStage lastSyncResult(Optional lastSyncResult); + + _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult); + + _FinalStage lastSyncFinished(Optional lastSyncFinished); + + _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished); + _FinalStage selectiveSyncConfigurationsUsage( Optional selectiveSyncConfigurationsUsage); @@ -177,12 +207,16 @@ public static final class Builder private String modelId; - private SyncStatusStatusEnum status; + private StatusFd5Enum status; private boolean isInitialSync; private Optional selectiveSyncConfigurationsUsage = Optional.empty(); + private Optional lastSyncFinished = Optional.empty(); + + private Optional lastSyncResult = Optional.empty(); + private Optional nextSyncStart = Optional.empty(); private Optional lastSyncStart = Optional.empty(); @@ -198,6 +232,8 @@ public Builder from(SyncStatus other) { modelId(other.getModelId()); lastSyncStart(other.getLastSyncStart()); nextSyncStart(other.getNextSyncStart()); + lastSyncResult(other.getLastSyncResult()); + lastSyncFinished(other.getLastSyncFinished()); status(other.getStatus()); isInitialSync(other.getIsInitialSync()); selectiveSyncConfigurationsUsage(other.getSelectiveSyncConfigurationsUsage()); @@ -220,7 +256,7 @@ public StatusStage modelId(@NotNull String modelId) { @java.lang.Override @JsonSetter("status") - public IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status) { + public IsInitialSyncStage status(@NotNull StatusFd5Enum status) { this.status = status; return this; } @@ -247,6 +283,32 @@ public _FinalStage selectiveSyncConfigurationsUsage( return this; } + @java.lang.Override + public _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished) { + this.lastSyncFinished = Optional.ofNullable(lastSyncFinished); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_finished", nulls = Nulls.SKIP) + public _FinalStage lastSyncFinished(Optional lastSyncFinished) { + this.lastSyncFinished = lastSyncFinished; + return this; + } + + @java.lang.Override + public _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult) { + this.lastSyncResult = Optional.ofNullable(lastSyncResult); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_result", nulls = Nulls.SKIP) + public _FinalStage lastSyncResult(Optional lastSyncResult) { + this.lastSyncResult = lastSyncResult; + return this; + } + @java.lang.Override public _FinalStage nextSyncStart(OffsetDateTime nextSyncStart) { this.nextSyncStart = Optional.ofNullable(nextSyncStart); @@ -280,6 +342,8 @@ public SyncStatus build() { modelId, lastSyncStart, nextSyncStart, + lastSyncResult, + lastSyncFinished, status, isInitialSync, selectiveSyncConfigurationsUsage, diff --git a/src/main/java/com/merge/api/resources/crm/types/SyncStatusStatusEnum.java b/src/main/java/com/merge/api/resources/crm/types/SyncStatusStatusEnum.java deleted file mode 100644 index dbcfe228e..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/SyncStatusStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SyncStatusStatusEnum { - SYNCING("SYNCING"), - - DONE("DONE"), - - FAILED("FAILED"), - - DISABLED("DISABLED"), - - PAUSED("PAUSED"), - - PARTIALLY_SYNCED("PARTIALLY_SYNCED"); - - private final String value; - - SyncStatusStatusEnum(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/Task.java b/src/main/java/com/merge/api/resources/crm/types/Task.java index 78a64c54d..4b691258a 100644 --- a/src/main/java/com/merge/api/resources/crm/types/Task.java +++ b/src/main/java/com/merge/api/resources/crm/types/Task.java @@ -45,7 +45,7 @@ public final class Task { private final Optional dueDate; - private final Optional status; + private final Optional status; private final Optional remoteWasDeleted; @@ -69,7 +69,7 @@ private Task( Optional opportunity, Optional completedDate, Optional dueDate, - Optional status, + Optional status, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -187,7 +187,7 @@ public Optional getDueDate() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -298,7 +298,7 @@ public static final class Builder { private Optional dueDate = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -455,12 +455,12 @@ public Builder dueDate(OffsetDateTime dueDate) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(TaskStatus status) { + public Builder status(TaskStatusEnum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/TaskAccount.java b/src/main/java/com/merge/api/resources/crm/types/TaskAccount.java index 317d35a2d..65804aee6 100644 --- a/src/main/java/com/merge/api/resources/crm/types/TaskAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/TaskAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TaskAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TaskAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/TaskOpportunity.java b/src/main/java/com/merge/api/resources/crm/types/TaskOpportunity.java index e3c59fd20..49867e7bd 100644 --- a/src/main/java/com/merge/api/resources/crm/types/TaskOpportunity.java +++ b/src/main/java/com/merge/api/resources/crm/types/TaskOpportunity.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TaskOpportunity deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TaskOpportunity deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/TaskOwner.java b/src/main/java/com/merge/api/resources/crm/types/TaskOwner.java index f0b1175a3..01b09585d 100644 --- a/src/main/java/com/merge/api/resources/crm/types/TaskOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/TaskOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TaskOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TaskOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/TaskRequest.java b/src/main/java/com/merge/api/resources/crm/types/TaskRequest.java index 92cf769d9..4e970f267 100644 --- a/src/main/java/com/merge/api/resources/crm/types/TaskRequest.java +++ b/src/main/java/com/merge/api/resources/crm/types/TaskRequest.java @@ -37,7 +37,7 @@ public final class TaskRequest { private final Optional dueDate; - private final Optional status; + private final Optional status; private final Optional> integrationParams; @@ -55,7 +55,7 @@ private TaskRequest( Optional opportunity, Optional completedDate, Optional dueDate, - Optional status, + Optional status, Optional> integrationParams, Optional> linkedAccountParams, Optional> remoteFields, @@ -138,7 +138,7 @@ public Optional getDueDate() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -223,7 +223,7 @@ public static final class Builder { private Optional dueDate = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -329,12 +329,12 @@ public Builder dueDate(OffsetDateTime dueDate) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(TaskRequestStatus status) { + public Builder status(TaskStatusEnum status) { this.status = Optional.ofNullable(status); return this; } diff --git a/src/main/java/com/merge/api/resources/crm/types/TaskRequestAccount.java b/src/main/java/com/merge/api/resources/crm/types/TaskRequestAccount.java index 89148c9df..a8ff910c1 100644 --- a/src/main/java/com/merge/api/resources/crm/types/TaskRequestAccount.java +++ b/src/main/java/com/merge/api/resources/crm/types/TaskRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TaskRequestAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TaskRequestAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/TaskRequestOpportunity.java b/src/main/java/com/merge/api/resources/crm/types/TaskRequestOpportunity.java index 7e7a3e8b1..e0a8d847c 100644 --- a/src/main/java/com/merge/api/resources/crm/types/TaskRequestOpportunity.java +++ b/src/main/java/com/merge/api/resources/crm/types/TaskRequestOpportunity.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public TaskRequestOpportunity deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TaskRequestOpportunity deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/TaskRequestOwner.java b/src/main/java/com/merge/api/resources/crm/types/TaskRequestOwner.java index 3ade35e23..3a67ed4c8 100644 --- a/src/main/java/com/merge/api/resources/crm/types/TaskRequestOwner.java +++ b/src/main/java/com/merge/api/resources/crm/types/TaskRequestOwner.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TaskRequestOwner deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TaskRequestOwner deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/crm/types/TaskRequestStatus.java b/src/main/java/com/merge/api/resources/crm/types/TaskRequestStatus.java deleted file mode 100644 index b3d79ad60..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/TaskRequestStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TaskRequestStatus.Deserializer.class) -public final class TaskRequestStatus { - private final Object value; - - private final int type; - - private TaskRequestStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TaskStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TaskRequestStatus && equalTo((TaskRequestStatus) other); - } - - private boolean equalTo(TaskRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TaskRequestStatus of(TaskStatusEnum value) { - return new TaskRequestStatus(value, 0); - } - - public static TaskRequestStatus of(String value) { - return new TaskRequestStatus(value, 1); - } - - public interface Visitor { - T visit(TaskStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TaskRequestStatus.class); - } - - @java.lang.Override - public TaskRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TaskStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/types/TaskStatus.java b/src/main/java/com/merge/api/resources/crm/types/TaskStatus.java deleted file mode 100644 index 3de681121..000000000 --- a/src/main/java/com/merge/api/resources/crm/types/TaskStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.crm.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TaskStatus.Deserializer.class) -public final class TaskStatus { - private final Object value; - - private final int type; - - private TaskStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TaskStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TaskStatus && equalTo((TaskStatus) other); - } - - private boolean equalTo(TaskStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TaskStatus of(TaskStatusEnum value) { - return new TaskStatus(value, 0); - } - - public static TaskStatus of(String value) { - return new TaskStatus(value, 1); - } - - public interface Visitor { - T visit(TaskStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TaskStatus.class); - } - - @java.lang.Override - public TaskStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TaskStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/crm/users/AsyncRawUsersClient.java b/src/main/java/com/merge/api/resources/crm/users/AsyncRawUsersClient.java new file mode 100644 index 000000000..db6e1881a --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/users/AsyncRawUsersClient.java @@ -0,0 +1,427 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.users; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.IgnoreCommonModelRequest; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.crm.types.PaginatedUserList; +import com.merge.api.resources.crm.types.User; +import com.merge.api.resources.crm.users.requests.UsersListRequest; +import com.merge.api.resources.crm.users.requests.UsersRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.users.requests.UsersRetrieveRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawUsersClient { + protected final ClientOptions clientOptions; + + public AsyncRawUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> list() { + return list(UsersListRequest.builder().build()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> list(UsersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> list( + UsersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/users"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email", request.getEmail().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, UsersRetrieveRequest.builder().build()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture> retrieve(String id, UsersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture> retrieve( + String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/users") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), User.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture> ignoreCreate( + String modelId, IgnoreCommonModelRequest request) { + return ignoreCreate(modelId, request, null); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture> ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/users/ignore") + .addPathSegment(modelId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + UsersRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + UsersRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + UsersRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/users/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/users/AsyncUsersClient.java b/src/main/java/com/merge/api/resources/crm/users/AsyncUsersClient.java new file mode 100644 index 000000000..383ca30d8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/users/AsyncUsersClient.java @@ -0,0 +1,113 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.users; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.IgnoreCommonModelRequest; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.crm.types.PaginatedUserList; +import com.merge.api.resources.crm.types.User; +import com.merge.api.resources.crm.users.requests.UsersListRequest; +import com.merge.api.resources.crm.users.requests.UsersRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.users.requests.UsersRetrieveRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncUsersClient { + protected final ClientOptions clientOptions; + + private final AsyncRawUsersClient rawClient; + + public AsyncUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawUsersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawUsersClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture list(UsersListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture list(UsersListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture retrieve(String id, UsersRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture retrieve(String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture ignoreCreate(String modelId, IgnoreCommonModelRequest request) { + return this.rawClient.ignoreCreate(modelId, request).thenApply(response -> response.body()); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + return this.rawClient.ignoreCreate(modelId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + UsersRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + UsersRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/users/RawUsersClient.java b/src/main/java/com/merge/api/resources/crm/users/RawUsersClient.java new file mode 100644 index 000000000..4e9eca96b --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/users/RawUsersClient.java @@ -0,0 +1,366 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.users; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.IgnoreCommonModelRequest; +import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.crm.types.PaginatedUserList; +import com.merge.api.resources.crm.types.User; +import com.merge.api.resources.crm.users.requests.UsersListRequest; +import com.merge.api.resources.crm.users.requests.UsersRemoteFieldClassesListRequest; +import com.merge.api.resources.crm.users.requests.UsersRetrieveRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawUsersClient { + protected final ClientOptions clientOptions; + + public RawUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse list() { + return list(UsersListRequest.builder().build()); + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse list(UsersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse list(UsersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/users"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email", request.getEmail().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a User object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, UsersRetrieveRequest.builder().build()); + } + + /** + * Returns a User object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, UsersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a User object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/users") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), User.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public MergeApiHttpResponse ignoreCreate(String modelId, IgnoreCommonModelRequest request) { + return ignoreCreate(modelId, request, null); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public MergeApiHttpResponse ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/users/ignore") + .addPathSegment(modelId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + UsersRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + UsersRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + UsersRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/users/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/users/UsersClient.java b/src/main/java/com/merge/api/resources/crm/users/UsersClient.java index 8865bb4fd..009565d22 100644 --- a/src/main/java/com/merge/api/resources/crm/users/UsersClient.java +++ b/src/main/java/com/merge/api/resources/crm/users/UsersClient.java @@ -3,12 +3,7 @@ */ package com.merge.api.resources.crm.users; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.types.IgnoreCommonModelRequest; import com.merge.api.resources.crm.types.PaginatedRemoteFieldClassList; @@ -17,233 +12,92 @@ import com.merge.api.resources.crm.users.requests.UsersListRequest; import com.merge.api.resources.crm.users.requests.UsersRemoteFieldClassesListRequest; import com.merge.api.resources.crm.users.requests.UsersRetrieveRequest; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class UsersClient { protected final ClientOptions clientOptions; + private final RawUsersClient rawClient; + public UsersClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawUsersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawUsersClient withRawResponse() { + return this.rawClient; } /** * Returns a list of User objects. */ public PaginatedUserList list() { - return list(UsersListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of User objects. */ public PaginatedUserList list(UsersListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of User objects. */ public PaginatedUserList list(UsersListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/users"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmail().isPresent()) { - httpUrl.addQueryParameter("email", request.getEmail().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a User object with the given id. */ public User retrieve(String id) { - return retrieve(id, UsersRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a User object with the given id. */ public User retrieve(String id, UsersRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a User object with the given id. */ public User retrieve(String id, UsersRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/users") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), User.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. */ public void ignoreCreate(String modelId, IgnoreCommonModelRequest request) { - ignoreCreate(modelId, request, null); + this.rawClient.ignoreCreate(modelId, request).body(); } /** * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. */ public void ignoreCreate(String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/users/ignore") - .addPathSegment(modelId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + this.rawClient.ignoreCreate(modelId, request, requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - UsersRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(UsersRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -251,61 +105,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(UsersRemoteFieldClas */ public PaginatedRemoteFieldClassList remoteFieldClassesList( UsersRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/users/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/crm/users/requests/UsersRetrieveRequest.java b/src/main/java/com/merge/api/resources/crm/users/requests/UsersRetrieveRequest.java index 41c2f2f97..88ee226af 100644 --- a/src/main/java/com/merge/api/resources/crm/users/requests/UsersRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/crm/users/requests/UsersRetrieveRequest.java @@ -24,14 +24,18 @@ public final class UsersRetrieveRequest { private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Map additionalProperties; private UsersRetrieveRequest( Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Map additionalProperties) { this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -51,6 +55,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +76,13 @@ public Map getAdditionalProperties() { private boolean equalTo(UsersRetrieveRequest other) { return includeRemoteData.equals(other.includeRemoteData) - && includeRemoteFields.equals(other.includeRemoteFields); + && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData, this.includeRemoteFields); + return Objects.hash(this.includeRemoteData, this.includeRemoteFields, this.includeShellData); } @java.lang.Override @@ -87,6 +100,8 @@ public static final class Builder { private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,6 +110,7 @@ private Builder() {} public Builder from(UsersRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); return this; } @@ -120,8 +136,20 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public UsersRetrieveRequest build() { - return new UsersRetrieveRequest(includeRemoteData, includeRemoteFields, additionalProperties); + return new UsersRetrieveRequest( + includeRemoteData, includeRemoteFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/crm/webhookreceivers/AsyncRawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/crm/webhookreceivers/AsyncRawWebhookReceiversClient.java new file mode 100644 index 000000000..499887f4c --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/webhookreceivers/AsyncRawWebhookReceiversClient.java @@ -0,0 +1,160 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.WebhookReceiver; +import com.merge.api.resources.crm.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public AsyncRawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create( + WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/crm/webhookreceivers/AsyncWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/crm/webhookreceivers/AsyncWebhookReceiversClient.java new file mode 100644 index 000000000..f1f9fc8c0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/webhookreceivers/AsyncWebhookReceiversClient.java @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.webhookreceivers; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.WebhookReceiver; +import com.merge.api.resources.crm.webhookreceivers.requests.WebhookReceiverRequest; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncWebhookReceiversClient { + protected final ClientOptions clientOptions; + + private final AsyncRawWebhookReceiversClient rawClient; + + public AsyncWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawWebhookReceiversClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/crm/webhookreceivers/RawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/crm/webhookreceivers/RawWebhookReceiversClient.java new file mode 100644 index 000000000..68e7cfe95 --- /dev/null +++ b/src/main/java/com/merge/api/resources/crm/webhookreceivers/RawWebhookReceiversClient.java @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.crm.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.crm.types.WebhookReceiver; +import com.merge.api.resources.crm.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public RawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("crm/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/crm/webhookreceivers/WebhookReceiversClient.java b/src/main/java/com/merge/api/resources/crm/webhookreceivers/WebhookReceiversClient.java index 00f82834d..daa0a3d1a 100644 --- a/src/main/java/com/merge/api/resources/crm/webhookreceivers/WebhookReceiversClient.java +++ b/src/main/java/com/merge/api/resources/crm/webhookreceivers/WebhookReceiversClient.java @@ -3,120 +3,54 @@ */ package com.merge.api.resources.crm.webhookreceivers; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.crm.types.WebhookReceiver; import com.merge.api.resources.crm.webhookreceivers.requests.WebhookReceiverRequest; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class WebhookReceiversClient { protected final ClientOptions clientOptions; + private final RawWebhookReceiversClient rawClient; + public WebhookReceiversClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawWebhookReceiversClient withRawResponse() { + return this.rawClient; } /** * Returns a list of WebhookReceiver objects. */ public List list() { - return list(null); + return this.rawClient.list().body(); } /** * Returns a list of WebhookReceiver objects. */ public List list(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/webhook-receivers") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(requestOptions).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("crm/v1/webhook-receivers") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/AsyncFileStorageClient.java b/src/main/java/com/merge/api/resources/filestorage/AsyncFileStorageClient.java new file mode 100644 index 000000000..cf8548951 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/AsyncFileStorageClient.java @@ -0,0 +1,192 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.Suppliers; +import com.merge.api.resources.filestorage.accountdetails.AsyncAccountDetailsClient; +import com.merge.api.resources.filestorage.accounttoken.AsyncAccountTokenClient; +import com.merge.api.resources.filestorage.asyncpassthrough.AsyncAsyncPassthroughClient; +import com.merge.api.resources.filestorage.audittrail.AsyncAuditTrailClient; +import com.merge.api.resources.filestorage.availableactions.AsyncAvailableActionsClient; +import com.merge.api.resources.filestorage.deleteaccount.AsyncDeleteAccountClient; +import com.merge.api.resources.filestorage.drives.AsyncDrivesClient; +import com.merge.api.resources.filestorage.fieldmapping.AsyncFieldMappingClient; +import com.merge.api.resources.filestorage.files.AsyncFilesClient; +import com.merge.api.resources.filestorage.folders.AsyncFoldersClient; +import com.merge.api.resources.filestorage.forceresync.AsyncForceResyncClient; +import com.merge.api.resources.filestorage.generatekey.AsyncGenerateKeyClient; +import com.merge.api.resources.filestorage.groups.AsyncGroupsClient; +import com.merge.api.resources.filestorage.issues.AsyncIssuesClient; +import com.merge.api.resources.filestorage.linkedaccounts.AsyncLinkedAccountsClient; +import com.merge.api.resources.filestorage.linktoken.AsyncLinkTokenClient; +import com.merge.api.resources.filestorage.passthrough.AsyncPassthroughClient; +import com.merge.api.resources.filestorage.regeneratekey.AsyncRegenerateKeyClient; +import com.merge.api.resources.filestorage.scopes.AsyncScopesClient; +import com.merge.api.resources.filestorage.syncstatus.AsyncSyncStatusClient; +import com.merge.api.resources.filestorage.users.AsyncUsersClient; +import com.merge.api.resources.filestorage.webhookreceivers.AsyncWebhookReceiversClient; +import java.util.function.Supplier; + +public class AsyncFileStorageClient { + protected final ClientOptions clientOptions; + + protected final Supplier accountDetailsClient; + + protected final Supplier accountTokenClient; + + protected final Supplier asyncPassthroughClient; + + protected final Supplier auditTrailClient; + + protected final Supplier availableActionsClient; + + protected final Supplier scopesClient; + + protected final Supplier deleteAccountClient; + + protected final Supplier drivesClient; + + protected final Supplier fieldMappingClient; + + protected final Supplier filesClient; + + protected final Supplier foldersClient; + + protected final Supplier generateKeyClient; + + protected final Supplier groupsClient; + + protected final Supplier issuesClient; + + protected final Supplier linkTokenClient; + + protected final Supplier linkedAccountsClient; + + protected final Supplier passthroughClient; + + protected final Supplier regenerateKeyClient; + + protected final Supplier syncStatusClient; + + protected final Supplier forceResyncClient; + + protected final Supplier usersClient; + + protected final Supplier webhookReceiversClient; + + public AsyncFileStorageClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.accountDetailsClient = Suppliers.memoize(() -> new AsyncAccountDetailsClient(clientOptions)); + this.accountTokenClient = Suppliers.memoize(() -> new AsyncAccountTokenClient(clientOptions)); + this.asyncPassthroughClient = Suppliers.memoize(() -> new AsyncAsyncPassthroughClient(clientOptions)); + this.auditTrailClient = Suppliers.memoize(() -> new AsyncAuditTrailClient(clientOptions)); + this.availableActionsClient = Suppliers.memoize(() -> new AsyncAvailableActionsClient(clientOptions)); + this.scopesClient = Suppliers.memoize(() -> new AsyncScopesClient(clientOptions)); + this.deleteAccountClient = Suppliers.memoize(() -> new AsyncDeleteAccountClient(clientOptions)); + this.drivesClient = Suppliers.memoize(() -> new AsyncDrivesClient(clientOptions)); + this.fieldMappingClient = Suppliers.memoize(() -> new AsyncFieldMappingClient(clientOptions)); + this.filesClient = Suppliers.memoize(() -> new AsyncFilesClient(clientOptions)); + this.foldersClient = Suppliers.memoize(() -> new AsyncFoldersClient(clientOptions)); + this.generateKeyClient = Suppliers.memoize(() -> new AsyncGenerateKeyClient(clientOptions)); + this.groupsClient = Suppliers.memoize(() -> new AsyncGroupsClient(clientOptions)); + this.issuesClient = Suppliers.memoize(() -> new AsyncIssuesClient(clientOptions)); + this.linkTokenClient = Suppliers.memoize(() -> new AsyncLinkTokenClient(clientOptions)); + this.linkedAccountsClient = Suppliers.memoize(() -> new AsyncLinkedAccountsClient(clientOptions)); + this.passthroughClient = Suppliers.memoize(() -> new AsyncPassthroughClient(clientOptions)); + this.regenerateKeyClient = Suppliers.memoize(() -> new AsyncRegenerateKeyClient(clientOptions)); + this.syncStatusClient = Suppliers.memoize(() -> new AsyncSyncStatusClient(clientOptions)); + this.forceResyncClient = Suppliers.memoize(() -> new AsyncForceResyncClient(clientOptions)); + this.usersClient = Suppliers.memoize(() -> new AsyncUsersClient(clientOptions)); + this.webhookReceiversClient = Suppliers.memoize(() -> new AsyncWebhookReceiversClient(clientOptions)); + } + + public AsyncAccountDetailsClient accountDetails() { + return this.accountDetailsClient.get(); + } + + public AsyncAccountTokenClient accountToken() { + return this.accountTokenClient.get(); + } + + public AsyncAsyncPassthroughClient asyncPassthrough() { + return this.asyncPassthroughClient.get(); + } + + public AsyncAuditTrailClient auditTrail() { + return this.auditTrailClient.get(); + } + + public AsyncAvailableActionsClient availableActions() { + return this.availableActionsClient.get(); + } + + public AsyncScopesClient scopes() { + return this.scopesClient.get(); + } + + public AsyncDeleteAccountClient deleteAccount() { + return this.deleteAccountClient.get(); + } + + public AsyncDrivesClient drives() { + return this.drivesClient.get(); + } + + public AsyncFieldMappingClient fieldMapping() { + return this.fieldMappingClient.get(); + } + + public AsyncFilesClient files() { + return this.filesClient.get(); + } + + public AsyncFoldersClient folders() { + return this.foldersClient.get(); + } + + public AsyncGenerateKeyClient generateKey() { + return this.generateKeyClient.get(); + } + + public AsyncGroupsClient groups() { + return this.groupsClient.get(); + } + + public AsyncIssuesClient issues() { + return this.issuesClient.get(); + } + + public AsyncLinkTokenClient linkToken() { + return this.linkTokenClient.get(); + } + + public AsyncLinkedAccountsClient linkedAccounts() { + return this.linkedAccountsClient.get(); + } + + public AsyncPassthroughClient passthrough() { + return this.passthroughClient.get(); + } + + public AsyncRegenerateKeyClient regenerateKey() { + return this.regenerateKeyClient.get(); + } + + public AsyncSyncStatusClient syncStatus() { + return this.syncStatusClient.get(); + } + + public AsyncForceResyncClient forceResync() { + return this.forceResyncClient.get(); + } + + public AsyncUsersClient users() { + return this.usersClient.get(); + } + + public AsyncWebhookReceiversClient webhookReceivers() { + return this.webhookReceiversClient.get(); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/FileStorageClient.java b/src/main/java/com/merge/api/resources/filestorage/FileStorageClient.java new file mode 100644 index 000000000..7cbd53e3e --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/FileStorageClient.java @@ -0,0 +1,192 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.Suppliers; +import com.merge.api.resources.filestorage.accountdetails.AccountDetailsClient; +import com.merge.api.resources.filestorage.accounttoken.AccountTokenClient; +import com.merge.api.resources.filestorage.asyncpassthrough.AsyncPassthroughClient; +import com.merge.api.resources.filestorage.audittrail.AuditTrailClient; +import com.merge.api.resources.filestorage.availableactions.AvailableActionsClient; +import com.merge.api.resources.filestorage.deleteaccount.DeleteAccountClient; +import com.merge.api.resources.filestorage.drives.DrivesClient; +import com.merge.api.resources.filestorage.fieldmapping.FieldMappingClient; +import com.merge.api.resources.filestorage.files.FilesClient; +import com.merge.api.resources.filestorage.folders.FoldersClient; +import com.merge.api.resources.filestorage.forceresync.ForceResyncClient; +import com.merge.api.resources.filestorage.generatekey.GenerateKeyClient; +import com.merge.api.resources.filestorage.groups.GroupsClient; +import com.merge.api.resources.filestorage.issues.IssuesClient; +import com.merge.api.resources.filestorage.linkedaccounts.LinkedAccountsClient; +import com.merge.api.resources.filestorage.linktoken.LinkTokenClient; +import com.merge.api.resources.filestorage.passthrough.PassthroughClient; +import com.merge.api.resources.filestorage.regeneratekey.RegenerateKeyClient; +import com.merge.api.resources.filestorage.scopes.ScopesClient; +import com.merge.api.resources.filestorage.syncstatus.SyncStatusClient; +import com.merge.api.resources.filestorage.users.UsersClient; +import com.merge.api.resources.filestorage.webhookreceivers.WebhookReceiversClient; +import java.util.function.Supplier; + +public class FileStorageClient { + protected final ClientOptions clientOptions; + + protected final Supplier accountDetailsClient; + + protected final Supplier accountTokenClient; + + protected final Supplier asyncPassthroughClient; + + protected final Supplier auditTrailClient; + + protected final Supplier availableActionsClient; + + protected final Supplier scopesClient; + + protected final Supplier deleteAccountClient; + + protected final Supplier drivesClient; + + protected final Supplier fieldMappingClient; + + protected final Supplier filesClient; + + protected final Supplier foldersClient; + + protected final Supplier generateKeyClient; + + protected final Supplier groupsClient; + + protected final Supplier issuesClient; + + protected final Supplier linkTokenClient; + + protected final Supplier linkedAccountsClient; + + protected final Supplier passthroughClient; + + protected final Supplier regenerateKeyClient; + + protected final Supplier syncStatusClient; + + protected final Supplier forceResyncClient; + + protected final Supplier usersClient; + + protected final Supplier webhookReceiversClient; + + public FileStorageClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.accountDetailsClient = Suppliers.memoize(() -> new AccountDetailsClient(clientOptions)); + this.accountTokenClient = Suppliers.memoize(() -> new AccountTokenClient(clientOptions)); + this.asyncPassthroughClient = Suppliers.memoize(() -> new AsyncPassthroughClient(clientOptions)); + this.auditTrailClient = Suppliers.memoize(() -> new AuditTrailClient(clientOptions)); + this.availableActionsClient = Suppliers.memoize(() -> new AvailableActionsClient(clientOptions)); + this.scopesClient = Suppliers.memoize(() -> new ScopesClient(clientOptions)); + this.deleteAccountClient = Suppliers.memoize(() -> new DeleteAccountClient(clientOptions)); + this.drivesClient = Suppliers.memoize(() -> new DrivesClient(clientOptions)); + this.fieldMappingClient = Suppliers.memoize(() -> new FieldMappingClient(clientOptions)); + this.filesClient = Suppliers.memoize(() -> new FilesClient(clientOptions)); + this.foldersClient = Suppliers.memoize(() -> new FoldersClient(clientOptions)); + this.generateKeyClient = Suppliers.memoize(() -> new GenerateKeyClient(clientOptions)); + this.groupsClient = Suppliers.memoize(() -> new GroupsClient(clientOptions)); + this.issuesClient = Suppliers.memoize(() -> new IssuesClient(clientOptions)); + this.linkTokenClient = Suppliers.memoize(() -> new LinkTokenClient(clientOptions)); + this.linkedAccountsClient = Suppliers.memoize(() -> new LinkedAccountsClient(clientOptions)); + this.passthroughClient = Suppliers.memoize(() -> new PassthroughClient(clientOptions)); + this.regenerateKeyClient = Suppliers.memoize(() -> new RegenerateKeyClient(clientOptions)); + this.syncStatusClient = Suppliers.memoize(() -> new SyncStatusClient(clientOptions)); + this.forceResyncClient = Suppliers.memoize(() -> new ForceResyncClient(clientOptions)); + this.usersClient = Suppliers.memoize(() -> new UsersClient(clientOptions)); + this.webhookReceiversClient = Suppliers.memoize(() -> new WebhookReceiversClient(clientOptions)); + } + + public AccountDetailsClient accountDetails() { + return this.accountDetailsClient.get(); + } + + public AccountTokenClient accountToken() { + return this.accountTokenClient.get(); + } + + public AsyncPassthroughClient asyncPassthrough() { + return this.asyncPassthroughClient.get(); + } + + public AuditTrailClient auditTrail() { + return this.auditTrailClient.get(); + } + + public AvailableActionsClient availableActions() { + return this.availableActionsClient.get(); + } + + public ScopesClient scopes() { + return this.scopesClient.get(); + } + + public DeleteAccountClient deleteAccount() { + return this.deleteAccountClient.get(); + } + + public DrivesClient drives() { + return this.drivesClient.get(); + } + + public FieldMappingClient fieldMapping() { + return this.fieldMappingClient.get(); + } + + public FilesClient files() { + return this.filesClient.get(); + } + + public FoldersClient folders() { + return this.foldersClient.get(); + } + + public GenerateKeyClient generateKey() { + return this.generateKeyClient.get(); + } + + public GroupsClient groups() { + return this.groupsClient.get(); + } + + public IssuesClient issues() { + return this.issuesClient.get(); + } + + public LinkTokenClient linkToken() { + return this.linkTokenClient.get(); + } + + public LinkedAccountsClient linkedAccounts() { + return this.linkedAccountsClient.get(); + } + + public PassthroughClient passthrough() { + return this.passthroughClient.get(); + } + + public RegenerateKeyClient regenerateKey() { + return this.regenerateKeyClient.get(); + } + + public SyncStatusClient syncStatus() { + return this.syncStatusClient.get(); + } + + public ForceResyncClient forceResync() { + return this.forceResyncClient.get(); + } + + public UsersClient users() { + return this.usersClient.get(); + } + + public WebhookReceiversClient webhookReceivers() { + return this.webhookReceiversClient.get(); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/FilestorageClient.java b/src/main/java/com/merge/api/resources/filestorage/FilestorageClient.java deleted file mode 100644 index dab6b895b..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/FilestorageClient.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage; - -import com.merge.api.core.ClientOptions; -import com.merge.api.core.Suppliers; -import com.merge.api.resources.filestorage.accountdetails.AccountDetailsClient; -import com.merge.api.resources.filestorage.accounttoken.AccountTokenClient; -import com.merge.api.resources.filestorage.asyncpassthrough.AsyncPassthroughClient; -import com.merge.api.resources.filestorage.audittrail.AuditTrailClient; -import com.merge.api.resources.filestorage.availableactions.AvailableActionsClient; -import com.merge.api.resources.filestorage.deleteaccount.DeleteAccountClient; -import com.merge.api.resources.filestorage.drives.DrivesClient; -import com.merge.api.resources.filestorage.fieldmapping.FieldMappingClient; -import com.merge.api.resources.filestorage.files.FilesClient; -import com.merge.api.resources.filestorage.folders.FoldersClient; -import com.merge.api.resources.filestorage.forceresync.ForceResyncClient; -import com.merge.api.resources.filestorage.generatekey.GenerateKeyClient; -import com.merge.api.resources.filestorage.groups.GroupsClient; -import com.merge.api.resources.filestorage.issues.IssuesClient; -import com.merge.api.resources.filestorage.linkedaccounts.LinkedAccountsClient; -import com.merge.api.resources.filestorage.linktoken.LinkTokenClient; -import com.merge.api.resources.filestorage.passthrough.PassthroughClient; -import com.merge.api.resources.filestorage.regeneratekey.RegenerateKeyClient; -import com.merge.api.resources.filestorage.scopes.ScopesClient; -import com.merge.api.resources.filestorage.syncstatus.SyncStatusClient; -import com.merge.api.resources.filestorage.users.UsersClient; -import com.merge.api.resources.filestorage.webhookreceivers.WebhookReceiversClient; -import java.util.function.Supplier; - -public class FilestorageClient { - protected final ClientOptions clientOptions; - - protected final Supplier accountDetailsClient; - - protected final Supplier accountTokenClient; - - protected final Supplier asyncPassthroughClient; - - protected final Supplier auditTrailClient; - - protected final Supplier availableActionsClient; - - protected final Supplier scopesClient; - - protected final Supplier deleteAccountClient; - - protected final Supplier drivesClient; - - protected final Supplier fieldMappingClient; - - protected final Supplier filesClient; - - protected final Supplier foldersClient; - - protected final Supplier generateKeyClient; - - protected final Supplier groupsClient; - - protected final Supplier issuesClient; - - protected final Supplier linkTokenClient; - - protected final Supplier linkedAccountsClient; - - protected final Supplier passthroughClient; - - protected final Supplier regenerateKeyClient; - - protected final Supplier syncStatusClient; - - protected final Supplier forceResyncClient; - - protected final Supplier usersClient; - - protected final Supplier webhookReceiversClient; - - public FilestorageClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.accountDetailsClient = Suppliers.memoize(() -> new AccountDetailsClient(clientOptions)); - this.accountTokenClient = Suppliers.memoize(() -> new AccountTokenClient(clientOptions)); - this.asyncPassthroughClient = Suppliers.memoize(() -> new AsyncPassthroughClient(clientOptions)); - this.auditTrailClient = Suppliers.memoize(() -> new AuditTrailClient(clientOptions)); - this.availableActionsClient = Suppliers.memoize(() -> new AvailableActionsClient(clientOptions)); - this.scopesClient = Suppliers.memoize(() -> new ScopesClient(clientOptions)); - this.deleteAccountClient = Suppliers.memoize(() -> new DeleteAccountClient(clientOptions)); - this.drivesClient = Suppliers.memoize(() -> new DrivesClient(clientOptions)); - this.fieldMappingClient = Suppliers.memoize(() -> new FieldMappingClient(clientOptions)); - this.filesClient = Suppliers.memoize(() -> new FilesClient(clientOptions)); - this.foldersClient = Suppliers.memoize(() -> new FoldersClient(clientOptions)); - this.generateKeyClient = Suppliers.memoize(() -> new GenerateKeyClient(clientOptions)); - this.groupsClient = Suppliers.memoize(() -> new GroupsClient(clientOptions)); - this.issuesClient = Suppliers.memoize(() -> new IssuesClient(clientOptions)); - this.linkTokenClient = Suppliers.memoize(() -> new LinkTokenClient(clientOptions)); - this.linkedAccountsClient = Suppliers.memoize(() -> new LinkedAccountsClient(clientOptions)); - this.passthroughClient = Suppliers.memoize(() -> new PassthroughClient(clientOptions)); - this.regenerateKeyClient = Suppliers.memoize(() -> new RegenerateKeyClient(clientOptions)); - this.syncStatusClient = Suppliers.memoize(() -> new SyncStatusClient(clientOptions)); - this.forceResyncClient = Suppliers.memoize(() -> new ForceResyncClient(clientOptions)); - this.usersClient = Suppliers.memoize(() -> new UsersClient(clientOptions)); - this.webhookReceiversClient = Suppliers.memoize(() -> new WebhookReceiversClient(clientOptions)); - } - - public AccountDetailsClient accountDetails() { - return this.accountDetailsClient.get(); - } - - public AccountTokenClient accountToken() { - return this.accountTokenClient.get(); - } - - public AsyncPassthroughClient asyncPassthrough() { - return this.asyncPassthroughClient.get(); - } - - public AuditTrailClient auditTrail() { - return this.auditTrailClient.get(); - } - - public AvailableActionsClient availableActions() { - return this.availableActionsClient.get(); - } - - public ScopesClient scopes() { - return this.scopesClient.get(); - } - - public DeleteAccountClient deleteAccount() { - return this.deleteAccountClient.get(); - } - - public DrivesClient drives() { - return this.drivesClient.get(); - } - - public FieldMappingClient fieldMapping() { - return this.fieldMappingClient.get(); - } - - public FilesClient files() { - return this.filesClient.get(); - } - - public FoldersClient folders() { - return this.foldersClient.get(); - } - - public GenerateKeyClient generateKey() { - return this.generateKeyClient.get(); - } - - public GroupsClient groups() { - return this.groupsClient.get(); - } - - public IssuesClient issues() { - return this.issuesClient.get(); - } - - public LinkTokenClient linkToken() { - return this.linkTokenClient.get(); - } - - public LinkedAccountsClient linkedAccounts() { - return this.linkedAccountsClient.get(); - } - - public PassthroughClient passthrough() { - return this.passthroughClient.get(); - } - - public RegenerateKeyClient regenerateKey() { - return this.regenerateKeyClient.get(); - } - - public SyncStatusClient syncStatus() { - return this.syncStatusClient.get(); - } - - public ForceResyncClient forceResync() { - return this.forceResyncClient.get(); - } - - public UsersClient users() { - return this.usersClient.get(); - } - - public WebhookReceiversClient webhookReceivers() { - return this.webhookReceiversClient.get(); - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/accountdetails/AccountDetailsClient.java b/src/main/java/com/merge/api/resources/filestorage/accountdetails/AccountDetailsClient.java index 84b0f6054..3f8c2a684 100644 --- a/src/main/java/com/merge/api/resources/filestorage/accountdetails/AccountDetailsClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/accountdetails/AccountDetailsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.filestorage.accountdetails; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.types.AccountDetails; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountDetailsClient { protected final ClientOptions clientOptions; + private final RawAccountDetailsClient rawClient; + public AccountDetailsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountDetailsClient withRawResponse() { + return this.rawClient; } /** * Get details for a linked account. */ public AccountDetails retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Get details for a linked account. */ public AccountDetails retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/account-details") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/accountdetails/AsyncAccountDetailsClient.java b/src/main/java/com/merge/api/resources/filestorage/accountdetails/AsyncAccountDetailsClient.java new file mode 100644 index 000000000..88a010d54 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/accountdetails/AsyncAccountDetailsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.accountdetails; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.AccountDetails; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountDetailsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountDetailsClient rawClient; + + public AsyncAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountDetailsClient withRawResponse() { + return this.rawClient; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/accountdetails/AsyncRawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/filestorage/accountdetails/AsyncRawAccountDetailsClient.java new file mode 100644 index 000000000..3d54e9821 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/accountdetails/AsyncRawAccountDetailsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.AccountDetails; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/accountdetails/RawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/filestorage/accountdetails/RawAccountDetailsClient.java new file mode 100644 index 000000000..f3e83a86e --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/accountdetails/RawAccountDetailsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.AccountDetails; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public RawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/accounttoken/AccountTokenClient.java b/src/main/java/com/merge/api/resources/filestorage/accounttoken/AccountTokenClient.java index b9296cd78..e029fec6b 100644 --- a/src/main/java/com/merge/api/resources/filestorage/accounttoken/AccountTokenClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/accounttoken/AccountTokenClient.java @@ -3,66 +3,38 @@ */ package com.merge.api.resources.filestorage.accounttoken; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.types.AccountToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountTokenClient { protected final ClientOptions clientOptions; + private final RawAccountTokenClient rawClient; + public AccountTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountTokenClient withRawResponse() { + return this.rawClient; } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken) { - return retrieve(publicToken, null); + return this.rawClient.retrieve(publicToken).body(); } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/account-token") - .addPathSegment(publicToken) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(publicToken, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/accounttoken/AsyncAccountTokenClient.java b/src/main/java/com/merge/api/resources/filestorage/accounttoken/AsyncAccountTokenClient.java new file mode 100644 index 000000000..53736af9c --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/accounttoken/AsyncAccountTokenClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.accounttoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.AccountToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountTokenClient rawClient; + + public AsyncAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken) { + return this.rawClient.retrieve(publicToken).thenApply(response -> response.body()); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken, RequestOptions requestOptions) { + return this.rawClient.retrieve(publicToken, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/accounttoken/AsyncRawAccountTokenClient.java b/src/main/java/com/merge/api/resources/filestorage/accounttoken/AsyncRawAccountTokenClient.java new file mode 100644 index 000000000..b65f336a8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/accounttoken/AsyncRawAccountTokenClient.java @@ -0,0 +1,90 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.AccountToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve( + String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/accounttoken/RawAccountTokenClient.java b/src/main/java/com/merge/api/resources/filestorage/accounttoken/RawAccountTokenClient.java new file mode 100644 index 000000000..6adf30640 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/accounttoken/RawAccountTokenClient.java @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.AccountToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountTokenClient { + protected final ClientOptions clientOptions; + + public RawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/AsyncAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/AsyncAsyncPassthroughClient.java new file mode 100644 index 000000000..cdb502591 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/AsyncAsyncPassthroughClient.java @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.asyncpassthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.filestorage.types.AsyncPassthroughReciept; +import com.merge.api.resources.filestorage.types.DataPassthroughRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAsyncPassthroughClient rawClient; + + public AsyncAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAsyncPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create( + DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve(String asyncPassthroughReceiptId) { + return this.rawClient.retrieve(asyncPassthroughReceiptId).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/AsyncPassthroughClient.java index a2f98a5b6..174e7f4c7 100644 --- a/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/AsyncPassthroughClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/AsyncPassthroughClient.java @@ -3,119 +3,56 @@ */ package com.merge.api.resources.filestorage.asyncpassthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; import com.merge.api.resources.filestorage.types.AsyncPassthroughReciept; import com.merge.api.resources.filestorage.types.DataPassthroughRequest; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AsyncPassthroughClient { protected final ClientOptions clientOptions; + private final RawAsyncPassthroughClient rawClient; + public AsyncPassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAsyncPassthroughClient withRawResponse() { + return this.rawClient; } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/async-passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId) { - return retrieve(asyncPassthroughReceiptId, null); + return this.rawClient.retrieve(asyncPassthroughReceiptId).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/async-passthrough") - .addPathSegment(asyncPassthroughReceiptId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), AsyncPassthroughRetrieveResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/AsyncRawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/AsyncRawAsyncPassthroughClient.java new file mode 100644 index 000000000..265e91dfd --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/AsyncRawAsyncPassthroughClient.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.filestorage.types.AsyncPassthroughReciept; +import com.merge.api.resources.filestorage.types.DataPassthroughRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughReciept.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/RawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/RawAsyncPassthroughClient.java new file mode 100644 index 000000000..db3e72857 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/RawAsyncPassthroughClient.java @@ -0,0 +1,131 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.filestorage.types.AsyncPassthroughReciept; +import com.merge.api.resources.filestorage.types.DataPassthroughRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public RawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve(String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java b/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java index 3bd9b0a11..3cc5ee8dc 100644 --- a/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java +++ b/src/main/java/com/merge/api/resources/filestorage/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java @@ -30,6 +30,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((RemoteResponse) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list(AuditTrailListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list( + AuditTrailListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/audittrail/AsyncRawAuditTrailClient.java b/src/main/java/com/merge/api/resources/filestorage/audittrail/AsyncRawAuditTrailClient.java new file mode 100644 index 000000000..1cc36fb82 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/audittrail/AsyncRawAuditTrailClient.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.filestorage.types.PaginatedAuditLogEventList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAuditTrailClient { + protected final ClientOptions clientOptions; + + public AsyncRawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAuditLogEventList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/audittrail/AuditTrailClient.java b/src/main/java/com/merge/api/resources/filestorage/audittrail/AuditTrailClient.java index 77b43d27d..f1bc329ee 100644 --- a/src/main/java/com/merge/api/resources/filestorage/audittrail/AuditTrailClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/audittrail/AuditTrailClient.java @@ -3,90 +3,46 @@ */ package com.merge.api.resources.filestorage.audittrail; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.audittrail.requests.AuditTrailListRequest; import com.merge.api.resources.filestorage.types.PaginatedAuditLogEventList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AuditTrailClient { protected final ClientOptions clientOptions; + private final RawAuditTrailClient rawClient; + public AuditTrailClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAuditTrailClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAuditTrailClient withRawResponse() { + return this.rawClient; } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list() { - return list(AuditTrailListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/audit-trail"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEventType().isPresent()) { - httpUrl.addQueryParameter("event_type", request.getEventType().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getUserEmail().isPresent()) { - httpUrl.addQueryParameter("user_email", request.getUserEmail().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/audittrail/RawAuditTrailClient.java b/src/main/java/com/merge/api/resources/filestorage/audittrail/RawAuditTrailClient.java new file mode 100644 index 000000000..6416e2fe2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/audittrail/RawAuditTrailClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.filestorage.types.PaginatedAuditLogEventList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAuditTrailClient { + protected final ClientOptions clientOptions; + + public RawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/audittrail/requests/AuditTrailListRequest.java b/src/main/java/com/merge/api/resources/filestorage/audittrail/requests/AuditTrailListRequest.java index 66dd4574b..0b046a0c3 100644 --- a/src/main/java/com/merge/api/resources/filestorage/audittrail/requests/AuditTrailListRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/audittrail/requests/AuditTrailListRequest.java @@ -68,7 +68,7 @@ public Optional getEndDate() { } /** - * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED + * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED */ @JsonProperty("event_type") public Optional getEventType() { diff --git a/src/main/java/com/merge/api/resources/filestorage/availableactions/AsyncAvailableActionsClient.java b/src/main/java/com/merge/api/resources/filestorage/availableactions/AsyncAvailableActionsClient.java new file mode 100644 index 000000000..fb90d27bc --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/availableactions/AsyncAvailableActionsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.availableactions; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.AvailableActions; +import java.util.concurrent.CompletableFuture; + +public class AsyncAvailableActionsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAvailableActionsClient rawClient; + + public AsyncAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAvailableActionsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/availableactions/AsyncRawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/filestorage/availableactions/AsyncRawAvailableActionsClient.java new file mode 100644 index 000000000..59bb62999 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/availableactions/AsyncRawAvailableActionsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.AvailableActions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/availableactions/AvailableActionsClient.java b/src/main/java/com/merge/api/resources/filestorage/availableactions/AvailableActionsClient.java index 3a77382a4..7c12ceeec 100644 --- a/src/main/java/com/merge/api/resources/filestorage/availableactions/AvailableActionsClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/availableactions/AvailableActionsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.filestorage.availableactions; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.types.AvailableActions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AvailableActionsClient { protected final ClientOptions clientOptions; + private final RawAvailableActionsClient rawClient; + public AvailableActionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAvailableActionsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/available-actions") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/availableactions/RawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/filestorage/availableactions/RawAvailableActionsClient.java new file mode 100644 index 000000000..cf02e8f3a --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/availableactions/RawAvailableActionsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.AvailableActions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public RawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/deleteaccount/AsyncDeleteAccountClient.java b/src/main/java/com/merge/api/resources/filestorage/deleteaccount/AsyncDeleteAccountClient.java new file mode 100644 index 000000000..cd63d2951 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/deleteaccount/AsyncDeleteAccountClient.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.deleteaccount; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import java.util.concurrent.CompletableFuture; + +public class AsyncDeleteAccountClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDeleteAccountClient rawClient; + + public AsyncDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDeleteAccountClient withRawResponse() { + return this.rawClient; + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete() { + return this.rawClient.delete().thenApply(response -> response.body()); + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete(RequestOptions requestOptions) { + return this.rawClient.delete(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/deleteaccount/AsyncRawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/filestorage/deleteaccount/AsyncRawDeleteAccountClient.java new file mode 100644 index 000000000..272b270e8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/deleteaccount/AsyncRawDeleteAccountClient.java @@ -0,0 +1,84 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public AsyncRawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/deleteaccount/DeleteAccountClient.java b/src/main/java/com/merge/api/resources/filestorage/deleteaccount/DeleteAccountClient.java index 782532c0b..510f7d841 100644 --- a/src/main/java/com/merge/api/resources/filestorage/deleteaccount/DeleteAccountClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/deleteaccount/DeleteAccountClient.java @@ -3,63 +3,37 @@ */ package com.merge.api.resources.filestorage.deleteaccount; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class DeleteAccountClient { protected final ClientOptions clientOptions; + private final RawDeleteAccountClient rawClient; + public DeleteAccountClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDeleteAccountClient withRawResponse() { + return this.rawClient; } /** * Delete a linked account. */ public void delete() { - delete(null); + this.rawClient.delete().body(); } /** * Delete a linked account. */ public void delete(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/delete-account") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + this.rawClient.delete(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/deleteaccount/RawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/filestorage/deleteaccount/RawDeleteAccountClient.java new file mode 100644 index 000000000..a8d2456ef --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/deleteaccount/RawDeleteAccountClient.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public RawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/drives/AsyncDrivesClient.java b/src/main/java/com/merge/api/resources/filestorage/drives/AsyncDrivesClient.java new file mode 100644 index 000000000..c57809b7b --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/drives/AsyncDrivesClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.drives; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.drives.requests.DrivesListRequest; +import com.merge.api.resources.filestorage.drives.requests.DrivesRetrieveRequest; +import com.merge.api.resources.filestorage.types.Drive; +import com.merge.api.resources.filestorage.types.PaginatedDriveList; +import java.util.concurrent.CompletableFuture; + +public class AsyncDrivesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDrivesClient rawClient; + + public AsyncDrivesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDrivesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDrivesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Drive objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Drive objects. + */ + public CompletableFuture list(DrivesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Drive objects. + */ + public CompletableFuture list(DrivesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Drive object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Drive object with the given id. + */ + public CompletableFuture retrieve(String id, DrivesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Drive object with the given id. + */ + public CompletableFuture retrieve(String id, DrivesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/drives/AsyncRawDrivesClient.java b/src/main/java/com/merge/api/resources/filestorage/drives/AsyncRawDrivesClient.java new file mode 100644 index 000000000..9f06ce2ae --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/drives/AsyncRawDrivesClient.java @@ -0,0 +1,233 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.drives; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.drives.requests.DrivesListRequest; +import com.merge.api.resources.filestorage.drives.requests.DrivesRetrieveRequest; +import com.merge.api.resources.filestorage.types.Drive; +import com.merge.api.resources.filestorage.types.PaginatedDriveList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDrivesClient { + protected final ClientOptions clientOptions; + + public AsyncRawDrivesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Drive objects. + */ + public CompletableFuture> list() { + return list(DrivesListRequest.builder().build()); + } + + /** + * Returns a list of Drive objects. + */ + public CompletableFuture> list(DrivesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Drive objects. + */ + public CompletableFuture> list( + DrivesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/drives"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedDriveList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Drive object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, DrivesRetrieveRequest.builder().build()); + } + + /** + * Returns a Drive object with the given id. + */ + public CompletableFuture> retrieve(String id, DrivesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Drive object with the given id. + */ + public CompletableFuture> retrieve( + String id, DrivesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/drives") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Drive.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/drives/DrivesClient.java b/src/main/java/com/merge/api/resources/filestorage/drives/DrivesClient.java index ca0e123f3..8094a30d0 100644 --- a/src/main/java/com/merge/api/resources/filestorage/drives/DrivesClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/drives/DrivesClient.java @@ -3,167 +3,69 @@ */ package com.merge.api.resources.filestorage.drives; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.drives.requests.DrivesListRequest; import com.merge.api.resources.filestorage.drives.requests.DrivesRetrieveRequest; import com.merge.api.resources.filestorage.types.Drive; import com.merge.api.resources.filestorage.types.PaginatedDriveList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class DrivesClient { protected final ClientOptions clientOptions; + private final RawDrivesClient rawClient; + public DrivesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawDrivesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDrivesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Drive objects. */ public PaginatedDriveList list() { - return list(DrivesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Drive objects. */ public PaginatedDriveList list(DrivesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Drive objects. */ public PaginatedDriveList list(DrivesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/drives"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedDriveList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Drive object with the given id. */ public Drive retrieve(String id) { - return retrieve(id, DrivesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Drive object with the given id. */ public Drive retrieve(String id, DrivesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Drive object with the given id. */ public Drive retrieve(String id, DrivesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/drives") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Drive.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/drives/RawDrivesClient.java b/src/main/java/com/merge/api/resources/filestorage/drives/RawDrivesClient.java new file mode 100644 index 000000000..9a37823e3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/drives/RawDrivesClient.java @@ -0,0 +1,201 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.drives; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.drives.requests.DrivesListRequest; +import com.merge.api.resources.filestorage.drives.requests.DrivesRetrieveRequest; +import com.merge.api.resources.filestorage.types.Drive; +import com.merge.api.resources.filestorage.types.PaginatedDriveList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDrivesClient { + protected final ClientOptions clientOptions; + + public RawDrivesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Drive objects. + */ + public MergeApiHttpResponse list() { + return list(DrivesListRequest.builder().build()); + } + + /** + * Returns a list of Drive objects. + */ + public MergeApiHttpResponse list(DrivesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Drive objects. + */ + public MergeApiHttpResponse list(DrivesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/drives"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedDriveList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Drive object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, DrivesRetrieveRequest.builder().build()); + } + + /** + * Returns a Drive object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, DrivesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Drive object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, DrivesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/drives") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Drive.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/drives/requests/DrivesRetrieveRequest.java b/src/main/java/com/merge/api/resources/filestorage/drives/requests/DrivesRetrieveRequest.java index f168df918..9bf198b95 100644 --- a/src/main/java/com/merge/api/resources/filestorage/drives/requests/DrivesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/drives/requests/DrivesRetrieveRequest.java @@ -22,10 +22,16 @@ public final class DrivesRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private DrivesRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private DrivesRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(DrivesRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(DrivesRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public DrivesRetrieveRequest build() { - return new DrivesRetrieveRequest(includeRemoteData, additionalProperties); + return new DrivesRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/filestorage/fieldmapping/AsyncFieldMappingClient.java b/src/main/java/com/merge/api/resources/filestorage/fieldmapping/AsyncFieldMappingClient.java new file mode 100644 index 000000000..1e7c033b8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/fieldmapping/AsyncFieldMappingClient.java @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.fieldmapping; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.filestorage.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.filestorage.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.filestorage.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.filestorage.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.filestorage.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.filestorage.types.FieldMappingInstanceResponse; +import com.merge.api.resources.filestorage.types.RemoteFieldApiResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncFieldMappingClient { + protected final ClientOptions clientOptions; + + private final AsyncRawFieldMappingClient rawClient; + + public AsyncFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawFieldMappingClient withRawResponse() { + return this.rawClient; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve() { + return this.rawClient.fieldMappingsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return this.rawClient.fieldMappingsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate(CreateFieldMappingRequest request) { + return this.rawClient.fieldMappingsCreate(request).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsCreate(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy(String fieldMappingId) { + return this.rawClient.fieldMappingsDestroy(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate(String fieldMappingId) { + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve() { + return this.rawClient.remoteFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return this.rawClient.remoteFieldsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve() { + return this.rawClient.targetFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve(RequestOptions requestOptions) { + return this.rawClient.targetFieldsRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/fieldmapping/AsyncRawFieldMappingClient.java b/src/main/java/com/merge/api/resources/filestorage/fieldmapping/AsyncRawFieldMappingClient.java new file mode 100644 index 000000000..b9efc5594 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/fieldmapping/AsyncRawFieldMappingClient.java @@ -0,0 +1,471 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.filestorage.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.filestorage.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.filestorage.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.filestorage.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.filestorage.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.filestorage.types.FieldMappingInstanceResponse; +import com.merge.api.resources.filestorage.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawFieldMappingClient { + protected final ClientOptions clientOptions; + + public AsyncRawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), RemoteFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/fieldmapping/FieldMappingClient.java b/src/main/java/com/merge/api/resources/filestorage/fieldmapping/FieldMappingClient.java index df0a81cff..bc7aa0a52 100644 --- a/src/main/java/com/merge/api/resources/filestorage/fieldmapping/FieldMappingClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/fieldmapping/FieldMappingClient.java @@ -3,12 +3,7 @@ */ package com.merge.api.resources.filestorage.fieldmapping; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.fieldmapping.requests.CreateFieldMappingRequest; import com.merge.api.resources.filestorage.fieldmapping.requests.FieldMappingsRetrieveRequest; @@ -18,36 +13,36 @@ import com.merge.api.resources.filestorage.types.FieldMappingApiInstanceResponse; import com.merge.api.resources.filestorage.types.FieldMappingInstanceResponse; import com.merge.api.resources.filestorage.types.RemoteFieldApiResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class FieldMappingClient { protected final ClientOptions clientOptions; + private final RawFieldMappingClient rawClient; + public FieldMappingClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawFieldMappingClient withRawResponse() { + return this.rawClient; } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve() { - return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + return this.rawClient.fieldMappingsRetrieve().body(); } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrieveRequest request) { - return fieldMappingsRetrieve(request, null); + return this.rawClient.fieldMappingsRetrieve(request).body(); } /** @@ -55,46 +50,14 @@ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrie */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve( FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), FieldMappingApiInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).body(); } /** * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingRequest request) { - return fieldMappingsCreate(request, null); + return this.rawClient.fieldMappingsCreate(request).body(); } /** @@ -102,102 +65,30 @@ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingReques */ public FieldMappingInstanceResponse fieldMappingsCreate( CreateFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("target_field_name", request.getTargetFieldName()); - properties.put("target_field_description", request.getTargetFieldDescription()); - properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); - properties.put("remote_method", request.getRemoteMethod()); - properties.put("remote_url_path", request.getRemoteUrlPath()); - properties.put("common_model_name", request.getCommonModelName()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsCreate(request, requestOptions).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId) { - return fieldMappingsDestroy(fieldMappingId, null); + return this.rawClient.fieldMappingsDestroy(fieldMappingId).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .body(); } /** * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappingId) { - return fieldMappingsPartialUpdate( - fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).body(); } /** @@ -205,7 +96,9 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappi */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request) { - return fieldMappingsPartialUpdate(fieldMappingId, request, null); + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .body(); } /** @@ -213,56 +106,23 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve() { - return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + return this.rawClient.remoteFieldsRetrieve().body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { - return remoteFieldsRetrieve(request, null); + return this.rawClient.remoteFieldsRetrieve(request).body(); } /** @@ -270,80 +130,20 @@ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest r */ public RemoteFieldApiResponse remoteFieldsRetrieve( RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/remote-fields"); - if (request.getCommonModels().isPresent()) { - httpUrl.addQueryParameter("common_models", request.getCommonModels().get()); - } - if (request.getIncludeExampleValues().isPresent()) { - httpUrl.addQueryParameter( - "include_example_values", request.getIncludeExampleValues().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve() { - return targetFieldsRetrieve(null); + return this.rawClient.targetFieldsRetrieve().body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/target-fields") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalTargetFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.targetFieldsRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/fieldmapping/RawFieldMappingClient.java b/src/main/java/com/merge/api/resources/filestorage/fieldmapping/RawFieldMappingClient.java new file mode 100644 index 000000000..803f96d70 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/fieldmapping/RawFieldMappingClient.java @@ -0,0 +1,380 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.filestorage.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.filestorage.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.filestorage.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.filestorage.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.filestorage.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.filestorage.types.FieldMappingInstanceResponse; +import com.merge.api.resources.filestorage.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawFieldMappingClient { + protected final ClientOptions clientOptions; + + public RawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate(CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy(String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate(String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/files/AsyncFilesClient.java b/src/main/java/com/merge/api/resources/filestorage/files/AsyncFilesClient.java new file mode 100644 index 000000000..aa59cd1d7 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/files/AsyncFilesClient.java @@ -0,0 +1,180 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.files; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.files.requests.FileStorageFileEndpointRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRequestMetaListRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRequestMetaRetrieveRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRetrieveRequest; +import com.merge.api.resources.filestorage.files.requests.FilesListRequest; +import com.merge.api.resources.filestorage.files.requests.FilesRetrieveRequest; +import com.merge.api.resources.filestorage.types.DownloadRequestMeta; +import com.merge.api.resources.filestorage.types.File; +import com.merge.api.resources.filestorage.types.FileStorageFileResponse; +import com.merge.api.resources.filestorage.types.MetaResponse; +import com.merge.api.resources.filestorage.types.PaginatedDownloadRequestMetaList; +import com.merge.api.resources.filestorage.types.PaginatedFileList; +import java.io.InputStream; +import java.util.concurrent.CompletableFuture; + +public class AsyncFilesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawFilesClient rawClient; + + public AsyncFilesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawFilesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawFilesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of File objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of File objects. + */ + public CompletableFuture list(FilesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of File objects. + */ + public CompletableFuture list(FilesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a File object with the given values. + */ + public CompletableFuture create(FileStorageFileEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a File object with the given values. + */ + public CompletableFuture create( + FileStorageFileEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a File object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a File object with the given id. + */ + public CompletableFuture retrieve(String id, FilesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a File object with the given id. + */ + public CompletableFuture retrieve(String id, FilesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture downloadRetrieve(String id) { + return this.rawClient.downloadRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture downloadRetrieve(String id, FilesDownloadRetrieveRequest request) { + return this.rawClient.downloadRetrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture downloadRetrieve( + String id, FilesDownloadRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.downloadRetrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public CompletableFuture downloadRequestMetaRetrieve(String id) { + return this.rawClient.downloadRequestMetaRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public CompletableFuture downloadRequestMetaRetrieve( + String id, FilesDownloadRequestMetaRetrieveRequest request) { + return this.rawClient.downloadRequestMetaRetrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public CompletableFuture downloadRequestMetaRetrieve( + String id, FilesDownloadRequestMetaRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient + .downloadRequestMetaRetrieve(id, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public CompletableFuture downloadRequestMetaList() { + return this.rawClient.downloadRequestMetaList().thenApply(response -> response.body()); + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public CompletableFuture downloadRequestMetaList( + FilesDownloadRequestMetaListRequest request) { + return this.rawClient.downloadRequestMetaList(request).thenApply(response -> response.body()); + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public CompletableFuture downloadRequestMetaList( + FilesDownloadRequestMetaListRequest request, RequestOptions requestOptions) { + return this.rawClient.downloadRequestMetaList(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for FileStorageFile POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for FileStorageFile POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/files/AsyncRawFilesClient.java b/src/main/java/com/merge/api/resources/filestorage/files/AsyncRawFilesClient.java new file mode 100644 index 000000000..7bd1d1d15 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/files/AsyncRawFilesClient.java @@ -0,0 +1,634 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.files; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.core.ResponseBodyInputStream; +import com.merge.api.resources.filestorage.files.requests.FileStorageFileEndpointRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRequestMetaListRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRequestMetaRetrieveRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRetrieveRequest; +import com.merge.api.resources.filestorage.files.requests.FilesListRequest; +import com.merge.api.resources.filestorage.files.requests.FilesRetrieveRequest; +import com.merge.api.resources.filestorage.types.DownloadRequestMeta; +import com.merge.api.resources.filestorage.types.File; +import com.merge.api.resources.filestorage.types.FileStorageFileResponse; +import com.merge.api.resources.filestorage.types.MetaResponse; +import com.merge.api.resources.filestorage.types.PaginatedDownloadRequestMetaList; +import com.merge.api.resources.filestorage.types.PaginatedFileList; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawFilesClient { + protected final ClientOptions clientOptions; + + public AsyncRawFilesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of File objects. + */ + public CompletableFuture> list() { + return list(FilesListRequest.builder().build()); + } + + /** + * Returns a list of File objects. + */ + public CompletableFuture> list(FilesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of File objects. + */ + public CompletableFuture> list( + FilesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getDriveId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "drive_id", request.getDriveId().get(), false); + } + if (request.getFolderId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "folder_id", request.getFolderId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getMimeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "mime_type", request.getMimeType().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedFileList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a File object with the given values. + */ + public CompletableFuture> create( + FileStorageFileEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a File object with the given values. + */ + public CompletableFuture> create( + FileStorageFileEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FileStorageFileResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a File object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, FilesRetrieveRequest.builder().build()); + } + + /** + * Returns a File object with the given id. + */ + public CompletableFuture> retrieve(String id, FilesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a File object with the given id. + */ + public CompletableFuture> retrieve( + String id, FilesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), File.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture> downloadRetrieve(String id) { + return downloadRetrieve(id, FilesDownloadRetrieveRequest.builder().build()); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture> downloadRetrieve( + String id, FilesDownloadRetrieveRequest request) { + return downloadRetrieve(id, request, null); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture> downloadRetrieve( + String id, FilesDownloadRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files") + .addPathSegment(id) + .addPathSegments("download"); + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getMimeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "mime_type", request.getMimeType().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(new ResponseBodyInputStream(response), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public CompletableFuture> downloadRequestMetaRetrieve(String id) { + return downloadRequestMetaRetrieve( + id, FilesDownloadRequestMetaRetrieveRequest.builder().build()); + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public CompletableFuture> downloadRequestMetaRetrieve( + String id, FilesDownloadRequestMetaRetrieveRequest request) { + return downloadRequestMetaRetrieve(id, request, null); + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public CompletableFuture> downloadRequestMetaRetrieve( + String id, FilesDownloadRequestMetaRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files") + .addPathSegment(id) + .addPathSegments("download/request-meta"); + if (request.getMimeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "mime_type", request.getMimeType().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DownloadRequestMeta.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public CompletableFuture> downloadRequestMetaList() { + return downloadRequestMetaList( + FilesDownloadRequestMetaListRequest.builder().build()); + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public CompletableFuture> downloadRequestMetaList( + FilesDownloadRequestMetaListRequest request) { + return downloadRequestMetaList(request, null); + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public CompletableFuture> downloadRequestMetaList( + FilesDownloadRequestMetaListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files/download/request-meta"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getMimeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "mime_type", request.getMimeType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedDownloadRequestMetaList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for FileStorageFile POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for FileStorageFile POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/files/FilesClient.java b/src/main/java/com/merge/api/resources/filestorage/files/FilesClient.java index 63935a96e..6ca815911 100644 --- a/src/main/java/com/merge/api/resources/filestorage/files/FilesClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/files/FilesClient.java @@ -3,263 +3,107 @@ */ package com.merge.api.resources.filestorage.files; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; -import com.merge.api.core.ResponseBodyInputStream; import com.merge.api.resources.filestorage.files.requests.FileStorageFileEndpointRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRequestMetaListRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRequestMetaRetrieveRequest; import com.merge.api.resources.filestorage.files.requests.FilesDownloadRetrieveRequest; import com.merge.api.resources.filestorage.files.requests.FilesListRequest; import com.merge.api.resources.filestorage.files.requests.FilesRetrieveRequest; +import com.merge.api.resources.filestorage.types.DownloadRequestMeta; import com.merge.api.resources.filestorage.types.File; import com.merge.api.resources.filestorage.types.FileStorageFileResponse; import com.merge.api.resources.filestorage.types.MetaResponse; +import com.merge.api.resources.filestorage.types.PaginatedDownloadRequestMetaList; import com.merge.api.resources.filestorage.types.PaginatedFileList; -import java.io.IOException; import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class FilesClient { protected final ClientOptions clientOptions; + private final RawFilesClient rawClient; + public FilesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawFilesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawFilesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of File objects. */ public PaginatedFileList list() { - return list(FilesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of File objects. */ public PaginatedFileList list(FilesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of File objects. */ public PaginatedFileList list(FilesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/files"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getDriveId().isPresent()) { - httpUrl.addQueryParameter("drive_id", request.getDriveId().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getFolderId().isPresent()) { - httpUrl.addQueryParameter("folder_id", request.getFolderId().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getMimeType().isPresent()) { - httpUrl.addQueryParameter("mime_type", request.getMimeType().get()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedFileList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a File object with the given values. */ public FileStorageFileResponse create(FileStorageFileEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a File object with the given values. */ public FileStorageFileResponse create(FileStorageFileEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/files"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileStorageFileResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a File object with the given id. */ public File retrieve(String id) { - return retrieve(id, FilesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a File object with the given id. */ public File retrieve(String id, FilesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a File object with the given id. */ public File retrieve(String id, FilesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/files") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), File.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns the File content with the given id as a stream of bytes. */ public InputStream downloadRetrieve(String id) { - return downloadRetrieve(id, FilesDownloadRetrieveRequest.builder().build()); + return this.rawClient.downloadRetrieve(id).body(); } /** * Returns the File content with the given id as a stream of bytes. */ public InputStream downloadRetrieve(String id, FilesDownloadRetrieveRequest request) { - return downloadRetrieve(id, request, null); + return this.rawClient.downloadRetrieve(id, request).body(); } /** @@ -267,78 +111,66 @@ public InputStream downloadRetrieve(String id, FilesDownloadRetrieveRequest requ */ public InputStream downloadRetrieve( String id, FilesDownloadRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/files") - .addPathSegment(id) - .addPathSegments("download"); - if (request.getMimeType().isPresent()) { - httpUrl.addQueryParameter("mime_type", request.getMimeType().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try { - Response response = client.newCall(okhttpRequest).execute(); - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new ResponseBodyInputStream(response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.downloadRetrieve(id, request, requestOptions).body(); + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public DownloadRequestMeta downloadRequestMetaRetrieve(String id) { + return this.rawClient.downloadRequestMetaRetrieve(id).body(); + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public DownloadRequestMeta downloadRequestMetaRetrieve(String id, FilesDownloadRequestMetaRetrieveRequest request) { + return this.rawClient.downloadRequestMetaRetrieve(id, request).body(); + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public DownloadRequestMeta downloadRequestMetaRetrieve( + String id, FilesDownloadRequestMetaRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient + .downloadRequestMetaRetrieve(id, request, requestOptions) + .body(); + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public PaginatedDownloadRequestMetaList downloadRequestMetaList() { + return this.rawClient.downloadRequestMetaList().body(); + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public PaginatedDownloadRequestMetaList downloadRequestMetaList(FilesDownloadRequestMetaListRequest request) { + return this.rawClient.downloadRequestMetaList(request).body(); + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public PaginatedDownloadRequestMetaList downloadRequestMetaList( + FilesDownloadRequestMetaListRequest request, RequestOptions requestOptions) { + return this.rawClient.downloadRequestMetaList(request, requestOptions).body(); } /** * Returns metadata for FileStorageFile POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for FileStorageFile POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/files/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/files/RawFilesClient.java b/src/main/java/com/merge/api/resources/filestorage/files/RawFilesClient.java new file mode 100644 index 000000000..542c74787 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/files/RawFilesClient.java @@ -0,0 +1,532 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.files; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.core.ResponseBodyInputStream; +import com.merge.api.resources.filestorage.files.requests.FileStorageFileEndpointRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRequestMetaListRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRequestMetaRetrieveRequest; +import com.merge.api.resources.filestorage.files.requests.FilesDownloadRetrieveRequest; +import com.merge.api.resources.filestorage.files.requests.FilesListRequest; +import com.merge.api.resources.filestorage.files.requests.FilesRetrieveRequest; +import com.merge.api.resources.filestorage.types.DownloadRequestMeta; +import com.merge.api.resources.filestorage.types.File; +import com.merge.api.resources.filestorage.types.FileStorageFileResponse; +import com.merge.api.resources.filestorage.types.MetaResponse; +import com.merge.api.resources.filestorage.types.PaginatedDownloadRequestMetaList; +import com.merge.api.resources.filestorage.types.PaginatedFileList; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawFilesClient { + protected final ClientOptions clientOptions; + + public RawFilesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of File objects. + */ + public MergeApiHttpResponse list() { + return list(FilesListRequest.builder().build()); + } + + /** + * Returns a list of File objects. + */ + public MergeApiHttpResponse list(FilesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of File objects. + */ + public MergeApiHttpResponse list(FilesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getDriveId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "drive_id", request.getDriveId().get(), false); + } + if (request.getFolderId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "folder_id", request.getFolderId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getMimeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "mime_type", request.getMimeType().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedFileList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a File object with the given values. + */ + public MergeApiHttpResponse create(FileStorageFileEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a File object with the given values. + */ + public MergeApiHttpResponse create( + FileStorageFileEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileStorageFileResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a File object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, FilesRetrieveRequest.builder().build()); + } + + /** + * Returns a File object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, FilesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a File object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, FilesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), File.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public MergeApiHttpResponse downloadRetrieve(String id) { + return downloadRetrieve(id, FilesDownloadRetrieveRequest.builder().build()); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public MergeApiHttpResponse downloadRetrieve(String id, FilesDownloadRetrieveRequest request) { + return downloadRetrieve(id, request, null); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public MergeApiHttpResponse downloadRetrieve( + String id, FilesDownloadRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files") + .addPathSegment(id) + .addPathSegments("download"); + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getMimeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "mime_type", request.getMimeType().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try { + Response response = client.newCall(okhttpRequest).execute(); + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(new ResponseBodyInputStream(response), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public MergeApiHttpResponse downloadRequestMetaRetrieve(String id) { + return downloadRequestMetaRetrieve( + id, FilesDownloadRequestMetaRetrieveRequest.builder().build()); + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public MergeApiHttpResponse downloadRequestMetaRetrieve( + String id, FilesDownloadRequestMetaRetrieveRequest request) { + return downloadRequestMetaRetrieve(id, request, null); + } + + /** + * Returns metadata to construct an authenticated file download request for a singular file, allowing you to download file directly from the third-party. + */ + public MergeApiHttpResponse downloadRequestMetaRetrieve( + String id, FilesDownloadRequestMetaRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files") + .addPathSegment(id) + .addPathSegments("download/request-meta"); + if (request.getMimeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "mime_type", request.getMimeType().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DownloadRequestMeta.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public MergeApiHttpResponse downloadRequestMetaList() { + return downloadRequestMetaList( + FilesDownloadRequestMetaListRequest.builder().build()); + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public MergeApiHttpResponse downloadRequestMetaList( + FilesDownloadRequestMetaListRequest request) { + return downloadRequestMetaList(request, null); + } + + /** + * Returns metadata to construct authenticated file download requests, allowing you to download files directly from the third-party. + */ + public MergeApiHttpResponse downloadRequestMetaList( + FilesDownloadRequestMetaListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files/download/request-meta"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getMimeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "mime_type", request.getMimeType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedDownloadRequestMetaList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for FileStorageFile POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for FileStorageFile POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/files/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesDownloadRequestMetaListRequest.java b/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesDownloadRequestMetaListRequest.java new file mode 100644 index 000000000..8a580eaa8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesDownloadRequestMetaListRequest.java @@ -0,0 +1,183 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.files.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = FilesDownloadRequestMetaListRequest.Builder.class) +public final class FilesDownloadRequestMetaListRequest { + private final Optional cursor; + + private final Optional includeDeletedData; + + private final Optional mimeType; + + private final Optional pageSize; + + private final Map additionalProperties; + + private FilesDownloadRequestMetaListRequest( + Optional cursor, + Optional includeDeletedData, + Optional mimeType, + Optional pageSize, + Map additionalProperties) { + this.cursor = cursor; + this.includeDeletedData = includeDeletedData; + this.mimeType = mimeType; + this.pageSize = pageSize; + this.additionalProperties = additionalProperties; + } + + /** + * @return The pagination cursor value. + */ + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; + } + + /** + * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. + */ + @JsonProperty("include_deleted_data") + public Optional getIncludeDeletedData() { + return includeDeletedData; + } + + /** + * @return If provided, specifies the export format of the files to be downloaded. For information on supported export formats, please refer to our <a href='https://help.merge.dev/en/articles/8615316-file-export-and-download-specification' target='_blank'>export format help center article</a>. + */ + @JsonProperty("mime_type") + public Optional getMimeType() { + return mimeType; + } + + /** + * @return Number of results to return per page. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FilesDownloadRequestMetaListRequest + && equalTo((FilesDownloadRequestMetaListRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FilesDownloadRequestMetaListRequest other) { + return cursor.equals(other.cursor) + && includeDeletedData.equals(other.includeDeletedData) + && mimeType.equals(other.mimeType) + && pageSize.equals(other.pageSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.cursor, this.includeDeletedData, this.mimeType, this.pageSize); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional cursor = Optional.empty(); + + private Optional includeDeletedData = Optional.empty(); + + private Optional mimeType = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(FilesDownloadRequestMetaListRequest other) { + cursor(other.getCursor()); + includeDeletedData(other.getIncludeDeletedData()); + mimeType(other.getMimeType()); + pageSize(other.getPageSize()); + return this; + } + + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); + return this; + } + + @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) + public Builder includeDeletedData(Optional includeDeletedData) { + this.includeDeletedData = includeDeletedData; + return this; + } + + public Builder includeDeletedData(Boolean includeDeletedData) { + this.includeDeletedData = Optional.ofNullable(includeDeletedData); + return this; + } + + @JsonSetter(value = "mime_type", nulls = Nulls.SKIP) + public Builder mimeType(Optional mimeType) { + this.mimeType = mimeType; + return this; + } + + public Builder mimeType(String mimeType) { + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) + public Builder pageSize(Optional pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder pageSize(Integer pageSize) { + this.pageSize = Optional.ofNullable(pageSize); + return this; + } + + public FilesDownloadRequestMetaListRequest build() { + return new FilesDownloadRequestMetaListRequest( + cursor, includeDeletedData, mimeType, pageSize, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesDownloadRequestMetaRetrieveRequest.java b/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesDownloadRequestMetaRetrieveRequest.java new file mode 100644 index 000000000..acb518343 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesDownloadRequestMetaRetrieveRequest.java @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.files.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = FilesDownloadRequestMetaRetrieveRequest.Builder.class) +public final class FilesDownloadRequestMetaRetrieveRequest { + private final Optional mimeType; + + private final Map additionalProperties; + + private FilesDownloadRequestMetaRetrieveRequest( + Optional mimeType, Map additionalProperties) { + this.mimeType = mimeType; + this.additionalProperties = additionalProperties; + } + + /** + * @return If provided, specifies the export format of the file to be downloaded. For information on supported export formats, please refer to our <a href='https://help.merge.dev/en/articles/8615316-file-export-and-download-specification' target='_blank'>export format help center article</a>. + */ + @JsonProperty("mime_type") + public Optional getMimeType() { + return mimeType; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof FilesDownloadRequestMetaRetrieveRequest + && equalTo((FilesDownloadRequestMetaRetrieveRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(FilesDownloadRequestMetaRetrieveRequest other) { + return mimeType.equals(other.mimeType); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.mimeType); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional mimeType = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(FilesDownloadRequestMetaRetrieveRequest other) { + mimeType(other.getMimeType()); + return this; + } + + @JsonSetter(value = "mime_type", nulls = Nulls.SKIP) + public Builder mimeType(Optional mimeType) { + this.mimeType = mimeType; + return this; + } + + public Builder mimeType(String mimeType) { + this.mimeType = Optional.ofNullable(mimeType); + return this; + } + + public FilesDownloadRequestMetaRetrieveRequest build() { + return new FilesDownloadRequestMetaRetrieveRequest(mimeType, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesDownloadRetrieveRequest.java b/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesDownloadRetrieveRequest.java index d96f7c137..bcb0e2966 100644 --- a/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesDownloadRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesDownloadRetrieveRequest.java @@ -20,15 +20,27 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FilesDownloadRetrieveRequest.Builder.class) public final class FilesDownloadRetrieveRequest { + private final Optional includeShellData; + private final Optional mimeType; private final Map additionalProperties; - private FilesDownloadRetrieveRequest(Optional mimeType, Map additionalProperties) { + private FilesDownloadRetrieveRequest( + Optional includeShellData, Optional mimeType, Map additionalProperties) { + this.includeShellData = includeShellData; this.mimeType = mimeType; this.additionalProperties = additionalProperties; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return If provided, specifies the export format of the file to be downloaded. For information on supported export formats, please refer to our <a href='https://help.merge.dev/en/articles/8615316-file-export-and-download-specification' target='_blank'>export format help center article</a>. */ @@ -49,12 +61,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(FilesDownloadRetrieveRequest other) { - return mimeType.equals(other.mimeType); + return includeShellData.equals(other.includeShellData) && mimeType.equals(other.mimeType); } @java.lang.Override public int hashCode() { - return Objects.hash(this.mimeType); + return Objects.hash(this.includeShellData, this.mimeType); } @java.lang.Override @@ -68,6 +80,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional includeShellData = Optional.empty(); + private Optional mimeType = Optional.empty(); @JsonAnySetter @@ -76,10 +90,22 @@ public static final class Builder { private Builder() {} public Builder from(FilesDownloadRetrieveRequest other) { + includeShellData(other.getIncludeShellData()); mimeType(other.getMimeType()); return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "mime_type", nulls = Nulls.SKIP) public Builder mimeType(Optional mimeType) { this.mimeType = mimeType; @@ -92,7 +118,7 @@ public Builder mimeType(String mimeType) { } public FilesDownloadRetrieveRequest build() { - return new FilesDownloadRetrieveRequest(mimeType, additionalProperties); + return new FilesDownloadRetrieveRequest(includeShellData, mimeType, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesListRequest.java b/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesListRequest.java index 486716aa1..3d2f022fc 100644 --- a/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesListRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.filestorage.files.types.FilesListRequestExpand; +import com.merge.api.resources.filestorage.files.types.FilesListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FilesListRequest.Builder.class) public final class FilesListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; @@ -30,8 +34,6 @@ public final class FilesListRequest { private final Optional driveId; - private final Optional expand; - private final Optional folderId; private final Optional includeDeletedData; @@ -55,11 +57,11 @@ public final class FilesListRequest { private final Map additionalProperties; private FilesListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, Optional driveId, - Optional expand, Optional folderId, Optional includeDeletedData, Optional includeRemoteData, @@ -71,11 +73,11 @@ private FilesListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.driveId = driveId; - this.expand = expand; this.folderId = folderId; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; @@ -89,6 +91,14 @@ private FilesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -121,14 +131,6 @@ public Optional getDriveId() { return driveId; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Specifying a folder id returns only the files in that folder. Specifying null returns only the files in root directory. */ @@ -221,11 +223,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(FilesListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && driveId.equals(other.driveId) - && expand.equals(other.expand) && folderId.equals(other.folderId) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) @@ -241,11 +243,11 @@ private boolean equalTo(FilesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, this.driveId, - this.expand, this.folderId, this.includeDeletedData, this.includeRemoteData, @@ -269,6 +271,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); @@ -277,8 +281,6 @@ public static final class Builder { private Optional driveId = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional folderId = Optional.empty(); private Optional includeDeletedData = Optional.empty(); @@ -305,11 +307,11 @@ public static final class Builder { private Builder() {} public Builder from(FilesListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); driveId(other.getDriveId()); - expand(other.getExpand()); folderId(other.getFolderId()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); @@ -323,6 +325,22 @@ public Builder from(FilesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(FilesListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -367,17 +385,6 @@ public Builder driveId(String driveId) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(FilesListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "folder_id", nulls = Nulls.SKIP) public Builder folderId(Optional folderId) { this.folderId = folderId; @@ -490,11 +497,11 @@ public Builder remoteId(String remoteId) { public FilesListRequest build() { return new FilesListRequest( + expand, createdAfter, createdBefore, cursor, driveId, - expand, folderId, includeDeletedData, includeRemoteData, diff --git a/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesRetrieveRequest.java b/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesRetrieveRequest.java index 1aedaca8c..7b80eb423 100644 --- a/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/files/requests/FilesRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.filestorage.files.types.FilesRetrieveRequestExpand; +import com.merge.api.resources.filestorage.files.types.FilesRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FilesRetrieveRequest.Builder.class) public final class FilesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private FilesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private FilesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(FilesRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -83,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,20 +113,26 @@ private Builder() {} public Builder from(FilesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(FilesRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(FilesRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -120,8 +144,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public FilesRetrieveRequest build() { - return new FilesRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new FilesRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/filestorage/files/types/FilesListRequestExpand.java b/src/main/java/com/merge/api/resources/filestorage/files/types/FilesListRequestExpand.java deleted file mode 100644 index aa5189316..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/files/types/FilesListRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum FilesListRequestExpand { - DRIVE("drive"), - - FOLDER("folder"), - - FOLDER_DRIVE("folder,drive"), - - PERMISSIONS("permissions"), - - PERMISSIONS_DRIVE("permissions,drive"), - - PERMISSIONS_FOLDER("permissions,folder"), - - PERMISSIONS_FOLDER_DRIVE("permissions,folder,drive"); - - private final String value; - - FilesListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/files/types/FilesListRequestExpandItem.java b/src/main/java/com/merge/api/resources/filestorage/files/types/FilesListRequestExpandItem.java new file mode 100644 index 000000000..f6556f860 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/files/types/FilesListRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum FilesListRequestExpandItem { + DRIVE("drive"), + + FOLDER("folder"), + + PERMISSIONS("permissions"); + + private final String value; + + FilesListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/files/types/FilesRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/filestorage/files/types/FilesRetrieveRequestExpand.java deleted file mode 100644 index c3afe7347..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/files/types/FilesRetrieveRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.files.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum FilesRetrieveRequestExpand { - DRIVE("drive"), - - FOLDER("folder"), - - FOLDER_DRIVE("folder,drive"), - - PERMISSIONS("permissions"), - - PERMISSIONS_DRIVE("permissions,drive"), - - PERMISSIONS_FOLDER("permissions,folder"), - - PERMISSIONS_FOLDER_DRIVE("permissions,folder,drive"); - - private final String value; - - FilesRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/files/types/FilesRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/filestorage/files/types/FilesRetrieveRequestExpandItem.java new file mode 100644 index 000000000..4376c4933 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/files/types/FilesRetrieveRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.files.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum FilesRetrieveRequestExpandItem { + DRIVE("drive"), + + FOLDER("folder"), + + PERMISSIONS("permissions"); + + private final String value; + + FilesRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/folders/AsyncFoldersClient.java b/src/main/java/com/merge/api/resources/filestorage/folders/AsyncFoldersClient.java new file mode 100644 index 000000000..730f56098 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/folders/AsyncFoldersClient.java @@ -0,0 +1,105 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.folders; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.folders.requests.FileStorageFolderEndpointRequest; +import com.merge.api.resources.filestorage.folders.requests.FoldersListRequest; +import com.merge.api.resources.filestorage.folders.requests.FoldersRetrieveRequest; +import com.merge.api.resources.filestorage.types.FileStorageFolderResponse; +import com.merge.api.resources.filestorage.types.Folder; +import com.merge.api.resources.filestorage.types.MetaResponse; +import com.merge.api.resources.filestorage.types.PaginatedFolderList; +import java.util.concurrent.CompletableFuture; + +public class AsyncFoldersClient { + protected final ClientOptions clientOptions; + + private final AsyncRawFoldersClient rawClient; + + public AsyncFoldersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawFoldersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawFoldersClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Folder objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Folder objects. + */ + public CompletableFuture list(FoldersListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Folder objects. + */ + public CompletableFuture list(FoldersListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Folder object with the given values. + */ + public CompletableFuture create(FileStorageFolderEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Folder object with the given values. + */ + public CompletableFuture create( + FileStorageFolderEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Folder object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Folder object with the given id. + */ + public CompletableFuture retrieve(String id, FoldersRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Folder object with the given id. + */ + public CompletableFuture retrieve( + String id, FoldersRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for FileStorageFolder POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for FileStorageFolder POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/folders/AsyncRawFoldersClient.java b/src/main/java/com/merge/api/resources/filestorage/folders/AsyncRawFoldersClient.java new file mode 100644 index 000000000..433224e08 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/folders/AsyncRawFoldersClient.java @@ -0,0 +1,389 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.folders; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.folders.requests.FileStorageFolderEndpointRequest; +import com.merge.api.resources.filestorage.folders.requests.FoldersListRequest; +import com.merge.api.resources.filestorage.folders.requests.FoldersRetrieveRequest; +import com.merge.api.resources.filestorage.types.FileStorageFolderResponse; +import com.merge.api.resources.filestorage.types.Folder; +import com.merge.api.resources.filestorage.types.MetaResponse; +import com.merge.api.resources.filestorage.types.PaginatedFolderList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawFoldersClient { + protected final ClientOptions clientOptions; + + public AsyncRawFoldersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Folder objects. + */ + public CompletableFuture> list() { + return list(FoldersListRequest.builder().build()); + } + + /** + * Returns a list of Folder objects. + */ + public CompletableFuture> list(FoldersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Folder objects. + */ + public CompletableFuture> list( + FoldersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/folders"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getDriveId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "drive_id", request.getDriveId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getParentFolderId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "parent_folder_id", request.getParentFolderId().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedFolderList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Folder object with the given values. + */ + public CompletableFuture> create( + FileStorageFolderEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Folder object with the given values. + */ + public CompletableFuture> create( + FileStorageFolderEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/folders"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FileStorageFolderResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Folder object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, FoldersRetrieveRequest.builder().build()); + } + + /** + * Returns a Folder object with the given id. + */ + public CompletableFuture> retrieve(String id, FoldersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Folder object with the given id. + */ + public CompletableFuture> retrieve( + String id, FoldersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/folders") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Folder.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for FileStorageFolder POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for FileStorageFolder POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/folders/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/folders/FoldersClient.java b/src/main/java/com/merge/api/resources/filestorage/folders/FoldersClient.java index a66deb6b3..062433652 100644 --- a/src/main/java/com/merge/api/resources/filestorage/folders/FoldersClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/folders/FoldersClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.filestorage.folders; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.folders.requests.FileStorageFolderEndpointRequest; import com.merge.api.resources.filestorage.folders.requests.FoldersListRequest; @@ -16,271 +12,91 @@ import com.merge.api.resources.filestorage.types.Folder; import com.merge.api.resources.filestorage.types.MetaResponse; import com.merge.api.resources.filestorage.types.PaginatedFolderList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class FoldersClient { protected final ClientOptions clientOptions; + private final RawFoldersClient rawClient; + public FoldersClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawFoldersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawFoldersClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Folder objects. */ public PaginatedFolderList list() { - return list(FoldersListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Folder objects. */ public PaginatedFolderList list(FoldersListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Folder objects. */ public PaginatedFolderList list(FoldersListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/folders"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getDriveId().isPresent()) { - httpUrl.addQueryParameter("drive_id", request.getDriveId().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getName().isPresent()) { - httpUrl.addQueryParameter("name", request.getName().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getParentFolderId().isPresent()) { - httpUrl.addQueryParameter( - "parent_folder_id", request.getParentFolderId().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedFolderList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Folder object with the given values. */ public FileStorageFolderResponse create(FileStorageFolderEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Folder object with the given values. */ public FileStorageFolderResponse create(FileStorageFolderEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/folders"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileStorageFolderResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Folder object with the given id. */ public Folder retrieve(String id) { - return retrieve(id, FoldersRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Folder object with the given id. */ public Folder retrieve(String id, FoldersRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Folder object with the given id. */ public Folder retrieve(String id, FoldersRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/folders") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Folder.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for FileStorageFolder POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for FileStorageFolder POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/folders/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/folders/RawFoldersClient.java b/src/main/java/com/merge/api/resources/filestorage/folders/RawFoldersClient.java new file mode 100644 index 000000000..bc90d8094 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/folders/RawFoldersClient.java @@ -0,0 +1,329 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.folders; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.folders.requests.FileStorageFolderEndpointRequest; +import com.merge.api.resources.filestorage.folders.requests.FoldersListRequest; +import com.merge.api.resources.filestorage.folders.requests.FoldersRetrieveRequest; +import com.merge.api.resources.filestorage.types.FileStorageFolderResponse; +import com.merge.api.resources.filestorage.types.Folder; +import com.merge.api.resources.filestorage.types.MetaResponse; +import com.merge.api.resources.filestorage.types.PaginatedFolderList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawFoldersClient { + protected final ClientOptions clientOptions; + + public RawFoldersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Folder objects. + */ + public MergeApiHttpResponse list() { + return list(FoldersListRequest.builder().build()); + } + + /** + * Returns a list of Folder objects. + */ + public MergeApiHttpResponse list(FoldersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Folder objects. + */ + public MergeApiHttpResponse list(FoldersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/folders"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getDriveId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "drive_id", request.getDriveId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "name", request.getName().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getParentFolderId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "parent_folder_id", request.getParentFolderId().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedFolderList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Folder object with the given values. + */ + public MergeApiHttpResponse create(FileStorageFolderEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Folder object with the given values. + */ + public MergeApiHttpResponse create( + FileStorageFolderEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/folders"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FileStorageFolderResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Folder object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, FoldersRetrieveRequest.builder().build()); + } + + /** + * Returns a Folder object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, FoldersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Folder object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, FoldersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/folders") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Folder.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for FileStorageFolder POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for FileStorageFolder POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/folders/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/folders/requests/FoldersListRequest.java b/src/main/java/com/merge/api/resources/filestorage/folders/requests/FoldersListRequest.java index 906b75c01..cbe55cc70 100644 --- a/src/main/java/com/merge/api/resources/filestorage/folders/requests/FoldersListRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/folders/requests/FoldersListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.filestorage.folders.types.FoldersListRequestExpand; +import com.merge.api.resources.filestorage.folders.types.FoldersListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FoldersListRequest.Builder.class) public final class FoldersListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; @@ -30,8 +34,6 @@ public final class FoldersListRequest { private final Optional driveId; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -53,11 +55,11 @@ public final class FoldersListRequest { private final Map additionalProperties; private FoldersListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, Optional driveId, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -68,11 +70,11 @@ private FoldersListRequest( Optional parentFolderId, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.driveId = driveId; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -85,6 +87,14 @@ private FoldersListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -117,14 +127,6 @@ public Optional getDriveId() { return driveId; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -209,11 +211,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(FoldersListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && driveId.equals(other.driveId) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -228,11 +230,11 @@ private boolean equalTo(FoldersListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, this.driveId, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -255,6 +257,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); @@ -263,8 +267,6 @@ public static final class Builder { private Optional driveId = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -289,11 +291,11 @@ public static final class Builder { private Builder() {} public Builder from(FoldersListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); driveId(other.getDriveId()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -306,6 +308,22 @@ public Builder from(FoldersListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(FoldersListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -350,17 +368,6 @@ public Builder driveId(String driveId) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(FoldersListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -462,11 +469,11 @@ public Builder remoteId(String remoteId) { public FoldersListRequest build() { return new FoldersListRequest( + expand, createdAfter, createdBefore, cursor, driveId, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/filestorage/folders/requests/FoldersRetrieveRequest.java b/src/main/java/com/merge/api/resources/filestorage/folders/requests/FoldersRetrieveRequest.java index e63f10763..768f27a15 100644 --- a/src/main/java/com/merge/api/resources/filestorage/folders/requests/FoldersRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/folders/requests/FoldersRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.filestorage.folders.types.FoldersRetrieveRequestExpand; +import com.merge.api.resources.filestorage.folders.types.FoldersRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = FoldersRetrieveRequest.Builder.class) public final class FoldersRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private FoldersRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private FoldersRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(FoldersRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -83,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,20 +113,26 @@ private Builder() {} public Builder from(FoldersRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(FoldersRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(FoldersRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -120,8 +144,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public FoldersRetrieveRequest build() { - return new FoldersRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new FoldersRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersListRequestExpand.java b/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersListRequestExpand.java deleted file mode 100644 index d6f9639c1..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersListRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.folders.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum FoldersListRequestExpand { - DRIVE("drive"), - - PARENT_FOLDER("parent_folder"), - - PARENT_FOLDER_DRIVE("parent_folder,drive"), - - PERMISSIONS("permissions"), - - PERMISSIONS_DRIVE("permissions,drive"), - - PERMISSIONS_PARENT_FOLDER("permissions,parent_folder"), - - PERMISSIONS_PARENT_FOLDER_DRIVE("permissions,parent_folder,drive"); - - private final String value; - - FoldersListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersListRequestExpandItem.java b/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersListRequestExpandItem.java new file mode 100644 index 000000000..daa908b61 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersListRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.folders.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum FoldersListRequestExpandItem { + DRIVE("drive"), + + PARENT_FOLDER("parent_folder"), + + PERMISSIONS("permissions"); + + private final String value; + + FoldersListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersRetrieveRequestExpand.java deleted file mode 100644 index 1a9fe5f33..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersRetrieveRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.folders.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum FoldersRetrieveRequestExpand { - DRIVE("drive"), - - PARENT_FOLDER("parent_folder"), - - PARENT_FOLDER_DRIVE("parent_folder,drive"), - - PERMISSIONS("permissions"), - - PERMISSIONS_DRIVE("permissions,drive"), - - PERMISSIONS_PARENT_FOLDER("permissions,parent_folder"), - - PERMISSIONS_PARENT_FOLDER_DRIVE("permissions,parent_folder,drive"); - - private final String value; - - FoldersRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersRetrieveRequestExpandItem.java new file mode 100644 index 000000000..8a2ce4866 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/folders/types/FoldersRetrieveRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.folders.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum FoldersRetrieveRequestExpandItem { + DRIVE("drive"), + + PARENT_FOLDER("parent_folder"), + + PERMISSIONS("permissions"); + + private final String value; + + FoldersRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/forceresync/AsyncForceResyncClient.java b/src/main/java/com/merge/api/resources/filestorage/forceresync/AsyncForceResyncClient.java new file mode 100644 index 000000000..68b75a7bb --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/forceresync/AsyncForceResyncClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.forceresync; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.SyncStatus; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncForceResyncClient { + protected final ClientOptions clientOptions; + + private final AsyncRawForceResyncClient rawClient; + + public AsyncForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawForceResyncClient withRawResponse() { + return this.rawClient; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate() { + return this.rawClient.syncStatusResyncCreate().thenApply(response -> response.body()); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate(RequestOptions requestOptions) { + return this.rawClient.syncStatusResyncCreate(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/forceresync/AsyncRawForceResyncClient.java b/src/main/java/com/merge/api/resources/filestorage/forceresync/AsyncRawForceResyncClient.java new file mode 100644 index 000000000..9e55f453c --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/forceresync/AsyncRawForceResyncClient.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawForceResyncClient { + protected final ClientOptions clientOptions; + + public AsyncRawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/forceresync/ForceResyncClient.java b/src/main/java/com/merge/api/resources/filestorage/forceresync/ForceResyncClient.java index dce262465..250f100c6 100644 --- a/src/main/java/com/merge/api/resources/filestorage/forceresync/ForceResyncClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/forceresync/ForceResyncClient.java @@ -3,69 +3,39 @@ */ package com.merge.api.resources.filestorage.forceresync; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.types.SyncStatus; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ForceResyncClient { protected final ClientOptions clientOptions; + private final RawForceResyncClient rawClient; + public ForceResyncClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawForceResyncClient withRawResponse() { + return this.rawClient; } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate() { - return syncStatusResyncCreate(null); + return this.rawClient.syncStatusResyncCreate().body(); } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/sync-status/resync") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.syncStatusResyncCreate(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/forceresync/RawForceResyncClient.java b/src/main/java/com/merge/api/resources/filestorage/forceresync/RawForceResyncClient.java new file mode 100644 index 000000000..03feec12d --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/forceresync/RawForceResyncClient.java @@ -0,0 +1,75 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawForceResyncClient { + protected final ClientOptions clientOptions; + + public RawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/generatekey/AsyncGenerateKeyClient.java b/src/main/java/com/merge/api/resources/filestorage/generatekey/AsyncGenerateKeyClient.java new file mode 100644 index 000000000..71c1c455f --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/generatekey/AsyncGenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.generatekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.filestorage.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncGenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawGenerateKeyClient rawClient; + + public AsyncGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawGenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/generatekey/AsyncRawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/filestorage/generatekey/AsyncRawGenerateKeyClient.java new file mode 100644 index 000000000..ff0530293 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/generatekey/AsyncRawGenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.filestorage.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public CompletableFuture> create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public CompletableFuture> create( + GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/generatekey/GenerateKeyClient.java b/src/main/java/com/merge/api/resources/filestorage/generatekey/GenerateKeyClient.java index e78d528d0..5cb1f3dc5 100644 --- a/src/main/java/com/merge/api/resources/filestorage/generatekey/GenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/generatekey/GenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.filestorage.generatekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.generatekey.requests.GenerateRemoteKeyRequest; import com.merge.api.resources.filestorage.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class GenerateKeyClient { protected final ClientOptions clientOptions; + private final RawGenerateKeyClient rawClient; + public GenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawGenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/generate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/generatekey/RawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/filestorage/generatekey/RawGenerateKeyClient.java new file mode 100644 index 000000000..b8bc084d7 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/generatekey/RawGenerateKeyClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.filestorage.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/groups/AsyncGroupsClient.java b/src/main/java/com/merge/api/resources/filestorage/groups/AsyncGroupsClient.java new file mode 100644 index 000000000..61556e51f --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/groups/AsyncGroupsClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.groups; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.groups.requests.GroupsListRequest; +import com.merge.api.resources.filestorage.groups.requests.GroupsRetrieveRequest; +import com.merge.api.resources.filestorage.types.Group; +import com.merge.api.resources.filestorage.types.PaginatedGroupList; +import java.util.concurrent.CompletableFuture; + +public class AsyncGroupsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawGroupsClient rawClient; + + public AsyncGroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawGroupsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawGroupsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture list(GroupsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture list(GroupsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture retrieve(String id, GroupsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture retrieve(String id, GroupsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/groups/AsyncRawGroupsClient.java b/src/main/java/com/merge/api/resources/filestorage/groups/AsyncRawGroupsClient.java new file mode 100644 index 000000000..7ddb3aca3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/groups/AsyncRawGroupsClient.java @@ -0,0 +1,237 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.groups; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.groups.requests.GroupsListRequest; +import com.merge.api.resources.filestorage.groups.requests.GroupsRetrieveRequest; +import com.merge.api.resources.filestorage.types.Group; +import com.merge.api.resources.filestorage.types.PaginatedGroupList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawGroupsClient { + protected final ClientOptions clientOptions; + + public AsyncRawGroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture> list() { + return list(GroupsListRequest.builder().build()); + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture> list(GroupsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture> list( + GroupsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/groups"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedGroupList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, GroupsRetrieveRequest.builder().build()); + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture> retrieve(String id, GroupsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture> retrieve( + String id, GroupsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/groups") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Group.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/groups/GroupsClient.java b/src/main/java/com/merge/api/resources/filestorage/groups/GroupsClient.java index cb7bb04c5..dc957fcc2 100644 --- a/src/main/java/com/merge/api/resources/filestorage/groups/GroupsClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/groups/GroupsClient.java @@ -3,170 +3,69 @@ */ package com.merge.api.resources.filestorage.groups; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.groups.requests.GroupsListRequest; import com.merge.api.resources.filestorage.groups.requests.GroupsRetrieveRequest; import com.merge.api.resources.filestorage.types.Group; import com.merge.api.resources.filestorage.types.PaginatedGroupList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class GroupsClient { protected final ClientOptions clientOptions; + private final RawGroupsClient rawClient; + public GroupsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawGroupsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawGroupsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Group objects. */ public PaginatedGroupList list() { - return list(GroupsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Group objects. */ public PaginatedGroupList list(GroupsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Group objects. */ public PaginatedGroupList list(GroupsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/groups"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedGroupList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Group object with the given id. */ public Group retrieve(String id) { - return retrieve(id, GroupsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Group object with the given id. */ public Group retrieve(String id, GroupsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Group object with the given id. */ public Group retrieve(String id, GroupsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/groups") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Group.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/groups/RawGroupsClient.java b/src/main/java/com/merge/api/resources/filestorage/groups/RawGroupsClient.java new file mode 100644 index 000000000..5ccbd2371 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/groups/RawGroupsClient.java @@ -0,0 +1,205 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.groups; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.groups.requests.GroupsListRequest; +import com.merge.api.resources.filestorage.groups.requests.GroupsRetrieveRequest; +import com.merge.api.resources.filestorage.types.Group; +import com.merge.api.resources.filestorage.types.PaginatedGroupList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawGroupsClient { + protected final ClientOptions clientOptions; + + public RawGroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Group objects. + */ + public MergeApiHttpResponse list() { + return list(GroupsListRequest.builder().build()); + } + + /** + * Returns a list of Group objects. + */ + public MergeApiHttpResponse list(GroupsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Group objects. + */ + public MergeApiHttpResponse list(GroupsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/groups"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedGroupList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Group object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, GroupsRetrieveRequest.builder().build()); + } + + /** + * Returns a Group object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, GroupsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Group object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, GroupsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/groups") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Group.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/groups/requests/GroupsListRequest.java b/src/main/java/com/merge/api/resources/filestorage/groups/requests/GroupsListRequest.java index dc153eeb5..53b593a0b 100644 --- a/src/main/java/com/merge/api/resources/filestorage/groups/requests/GroupsListRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/groups/requests/GroupsListRequest.java @@ -12,8 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import com.merge.api.resources.filestorage.groups.types.GroupsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,14 +24,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GroupsListRequest.Builder.class) public final class GroupsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -46,10 +49,10 @@ public final class GroupsListRequest { private final Map additionalProperties; private GroupsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -58,10 +61,10 @@ private GroupsListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -72,6 +75,14 @@ private GroupsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -96,14 +107,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -172,10 +175,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(GroupsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -188,10 +191,10 @@ private boolean equalTo(GroupsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -212,14 +215,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -240,10 +243,10 @@ public static final class Builder { private Builder() {} public Builder from(GroupsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -254,6 +257,22 @@ public Builder from(GroupsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(GroupsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -287,17 +306,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -377,10 +385,10 @@ public Builder remoteId(String remoteId) { public GroupsListRequest build() { return new GroupsListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/filestorage/groups/requests/GroupsRetrieveRequest.java b/src/main/java/com/merge/api/resources/filestorage/groups/requests/GroupsRetrieveRequest.java index 5b4cade80..e5b2af6f9 100644 --- a/src/main/java/com/merge/api/resources/filestorage/groups/requests/GroupsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/groups/requests/GroupsRetrieveRequest.java @@ -12,7 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import com.merge.api.resources.filestorage.groups.types.GroupsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = GroupsRetrieveRequest.Builder.class) public final class GroupsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private GroupsRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +46,7 @@ private GroupsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(GroupsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +113,26 @@ private Builder() {} public Builder from(GroupsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(GroupsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +144,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public GroupsRetrieveRequest build() { - return new GroupsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new GroupsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/filestorage/groups/types/GroupsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/filestorage/groups/types/GroupsListRequestExpandItem.java new file mode 100644 index 000000000..ac50d3038 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/groups/types/GroupsListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.groups.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum GroupsListRequestExpandItem { + CHILD_GROUPS("child_groups"), + + USERS("users"); + + private final String value; + + GroupsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/groups/types/GroupsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/filestorage/groups/types/GroupsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..fc5ba025e --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/groups/types/GroupsRetrieveRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.groups.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum GroupsRetrieveRequestExpandItem { + CHILD_GROUPS("child_groups"), + + USERS("users"); + + private final String value; + + GroupsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/issues/AsyncIssuesClient.java b/src/main/java/com/merge/api/resources/filestorage/issues/AsyncIssuesClient.java new file mode 100644 index 000000000..061bafe01 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/issues/AsyncIssuesClient.java @@ -0,0 +1,64 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.issues; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.issues.requests.IssuesListRequest; +import com.merge.api.resources.filestorage.types.Issue; +import com.merge.api.resources.filestorage.types.PaginatedIssueList; +import java.util.concurrent.CompletableFuture; + +public class AsyncIssuesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawIssuesClient rawClient; + + public AsyncIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawIssuesClient withRawResponse() { + return this.rawClient; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/issues/AsyncRawIssuesClient.java b/src/main/java/com/merge/api/resources/filestorage/issues/AsyncRawIssuesClient.java new file mode 100644 index 000000000..7807f3c88 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/issues/AsyncRawIssuesClient.java @@ -0,0 +1,226 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.issues.requests.IssuesListRequest; +import com.merge.api.resources.filestorage.types.Issue; +import com.merge.api.resources.filestorage.types.PaginatedIssueList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawIssuesClient { + protected final ClientOptions clientOptions; + + public AsyncRawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list( + IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/issues/IssuesClient.java b/src/main/java/com/merge/api/resources/filestorage/issues/IssuesClient.java index b259f9023..9d223e0e1 100644 --- a/src/main/java/com/merge/api/resources/filestorage/issues/IssuesClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/issues/IssuesClient.java @@ -3,169 +3,61 @@ */ package com.merge.api.resources.filestorage.issues; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.issues.requests.IssuesListRequest; import com.merge.api.resources.filestorage.types.Issue; import com.merge.api.resources.filestorage.types.PaginatedIssueList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class IssuesClient { protected final ClientOptions clientOptions; + private final RawIssuesClient rawClient; + public IssuesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawIssuesClient withRawResponse() { + return this.rawClient; } /** * Gets all issues for Organization. */ public PaginatedIssueList list() { - return list(IssuesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/issues"); - if (request.getAccountToken().isPresent()) { - httpUrl.addQueryParameter("account_token", request.getAccountToken().get()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getFirstIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_after", - request.getFirstIncidentTimeAfter().get().toString()); - } - if (request.getFirstIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_before", - request.getFirstIncidentTimeBefore().get().toString()); - } - if (request.getIncludeMuted().isPresent()) { - httpUrl.addQueryParameter("include_muted", request.getIncludeMuted().get()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getLastIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_after", - request.getLastIncidentTimeAfter().get().toString()); - } - if (request.getLastIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_before", - request.getLastIncidentTimeBefore().get().toString()); - } - if (request.getLinkedAccountId().isPresent()) { - httpUrl.addQueryParameter( - "linked_account_id", request.getLinkedAccountId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Get a specific issue. */ public Issue retrieve(String id) { - return retrieve(id, null); + return this.rawClient.retrieve(id).body(); } /** * Get a specific issue. */ public Issue retrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/issues") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/issues/RawIssuesClient.java b/src/main/java/com/merge/api/resources/filestorage/issues/RawIssuesClient.java new file mode 100644 index 000000000..58bc30297 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/issues/RawIssuesClient.java @@ -0,0 +1,194 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.issues.requests.IssuesListRequest; +import com.merge.api.resources.filestorage.types.Issue; +import com.merge.api.resources.filestorage.types.PaginatedIssueList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawIssuesClient { + protected final ClientOptions clientOptions; + + public RawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/AsyncLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/AsyncLinkedAccountsClient.java new file mode 100644 index 000000000..6e1d19c1a --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/AsyncLinkedAccountsClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.linkedaccounts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.filestorage.types.PaginatedAccountDetailsAndActionsList; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkedAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkedAccountsClient rawClient; + + public AsyncLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkedAccountsClient withRawResponse() { + return this.rawClient; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list(LinkedAccountsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/AsyncRawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/AsyncRawLinkedAccountsClient.java new file mode 100644 index 000000000..2126bf819 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/AsyncRawLinkedAccountsClient.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.filestorage.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/LinkedAccountsClient.java b/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/LinkedAccountsClient.java index 19e083762..14990a9a7 100644 --- a/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/LinkedAccountsClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/LinkedAccountsClient.java @@ -3,40 +3,40 @@ */ package com.merge.api.resources.filestorage.linkedaccounts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.linkedaccounts.requests.LinkedAccountsListRequest; import com.merge.api.resources.filestorage.types.PaginatedAccountDetailsAndActionsList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkedAccountsClient { protected final ClientOptions clientOptions; + private final RawLinkedAccountsClient rawClient; + public LinkedAccountsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkedAccountsClient withRawResponse() { + return this.rawClient; } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list() { - return list(LinkedAccountsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** @@ -44,80 +44,6 @@ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest requ */ public PaginatedAccountDetailsAndActionsList list( LinkedAccountsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/linked-accounts"); - if (request.getCategory().isPresent()) { - httpUrl.addQueryParameter("category", request.getCategory().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndUserEmailAddress().isPresent()) { - httpUrl.addQueryParameter( - "end_user_email_address", request.getEndUserEmailAddress().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getEndUserOriginId().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_id", request.getEndUserOriginId().get()); - } - if (request.getEndUserOriginIds().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_ids", request.getEndUserOriginIds().get()); - } - if (request.getId().isPresent()) { - httpUrl.addQueryParameter("id", request.getId().get()); - } - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getIncludeDuplicates().isPresent()) { - httpUrl.addQueryParameter( - "include_duplicates", request.getIncludeDuplicates().get().toString()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getIsTestAccount().isPresent()) { - httpUrl.addQueryParameter( - "is_test_account", request.getIsTestAccount().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedAccountDetailsAndActionsList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/RawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/RawLinkedAccountsClient.java new file mode 100644 index 000000000..f062aa195 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/linkedaccounts/RawLinkedAccountsClient.java @@ -0,0 +1,143 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.filestorage.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public RawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list(LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/linktoken/AsyncLinkTokenClient.java b/src/main/java/com/merge/api/resources/filestorage/linktoken/AsyncLinkTokenClient.java new file mode 100644 index 000000000..ed3747096 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/linktoken/AsyncLinkTokenClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.linktoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.filestorage.types.LinkToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkTokenClient rawClient; + + public AsyncLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/linktoken/AsyncRawLinkTokenClient.java b/src/main/java/com/merge/api/resources/filestorage/linktoken/AsyncRawLinkTokenClient.java new file mode 100644 index 000000000..06b1737fc --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/linktoken/AsyncRawLinkTokenClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.filestorage.types.LinkToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create( + EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/linktoken/LinkTokenClient.java b/src/main/java/com/merge/api/resources/filestorage/linktoken/LinkTokenClient.java index 445a4c7df..d01ff437e 100644 --- a/src/main/java/com/merge/api/resources/filestorage/linktoken/LinkTokenClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/linktoken/LinkTokenClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.filestorage.linktoken; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.linktoken.requests.EndUserDetailsRequest; import com.merge.api.resources.filestorage.types.LinkToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkTokenClient { protected final ClientOptions clientOptions; + private final RawLinkTokenClient rawClient; + public LinkTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkTokenClient withRawResponse() { + return this.rawClient; } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/link-token") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/linktoken/RawLinkTokenClient.java b/src/main/java/com/merge/api/resources/filestorage/linktoken/RawLinkTokenClient.java new file mode 100644 index 000000000..d8c3a5f6a --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/linktoken/RawLinkTokenClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.filestorage.types.LinkToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkTokenClient { + protected final ClientOptions clientOptions; + + public RawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/passthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/filestorage/passthrough/AsyncPassthroughClient.java new file mode 100644 index 000000000..8ac381dfa --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/passthrough/AsyncPassthroughClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.passthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.DataPassthroughRequest; +import com.merge.api.resources.filestorage.types.RemoteResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPassthroughClient rawClient; + + public AsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/passthrough/AsyncRawPassthroughClient.java b/src/main/java/com/merge/api/resources/filestorage/passthrough/AsyncRawPassthroughClient.java new file mode 100644 index 000000000..5cf57a491 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/passthrough/AsyncRawPassthroughClient.java @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.DataPassthroughRequest; +import com.merge.api.resources.filestorage.types.RemoteResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/passthrough/PassthroughClient.java b/src/main/java/com/merge/api/resources/filestorage/passthrough/PassthroughClient.java index 7e2086ad9..bad097401 100644 --- a/src/main/java/com/merge/api/resources/filestorage/passthrough/PassthroughClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/passthrough/PassthroughClient.java @@ -3,75 +3,39 @@ */ package com.merge.api.resources.filestorage.passthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.types.DataPassthroughRequest; import com.merge.api.resources.filestorage.types.RemoteResponse; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PassthroughClient { protected final ClientOptions clientOptions; + private final RawPassthroughClient rawClient; + public PassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPassthroughClient withRawResponse() { + return this.rawClient; } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/passthrough/RawPassthroughClient.java b/src/main/java/com/merge/api/resources/filestorage/passthrough/RawPassthroughClient.java new file mode 100644 index 000000000..f54a3f55a --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/passthrough/RawPassthroughClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.DataPassthroughRequest; +import com.merge.api.resources.filestorage.types.RemoteResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPassthroughClient { + protected final ClientOptions clientOptions; + + public RawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/regeneratekey/AsyncRawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/filestorage/regeneratekey/AsyncRawRegenerateKeyClient.java new file mode 100644 index 000000000..ad5742e52 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/regeneratekey/AsyncRawRegenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.filestorage.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/regeneratekey/AsyncRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/filestorage/regeneratekey/AsyncRegenerateKeyClient.java new file mode 100644 index 000000000..2af67b004 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/regeneratekey/AsyncRegenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.regeneratekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.filestorage.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncRegenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawRegenerateKeyClient rawClient; + + public AsyncRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawRegenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/regeneratekey/RawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/filestorage/regeneratekey/RawRegenerateKeyClient.java new file mode 100644 index 000000000..405e9edd1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/regeneratekey/RawRegenerateKeyClient.java @@ -0,0 +1,82 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.filestorage.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/regeneratekey/RegenerateKeyClient.java b/src/main/java/com/merge/api/resources/filestorage/regeneratekey/RegenerateKeyClient.java index cf8d0d7d1..7d16e5e75 100644 --- a/src/main/java/com/merge/api/resources/filestorage/regeneratekey/RegenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/regeneratekey/RegenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.filestorage.regeneratekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.regeneratekey.requests.RemoteKeyForRegenerationRequest; import com.merge.api.resources.filestorage.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class RegenerateKeyClient { protected final ClientOptions clientOptions; + private final RawRegenerateKeyClient rawClient; + public RegenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawRegenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/regenerate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/scopes/AsyncRawScopesClient.java b/src/main/java/com/merge/api/resources/filestorage/scopes/AsyncRawScopesClient.java new file mode 100644 index 000000000..4dd110029 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/scopes/AsyncRawScopesClient.java @@ -0,0 +1,217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.filestorage.types.CommonModelScopeApi; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawScopesClient { + protected final ClientOptions clientOptions; + + public AsyncRawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/scopes/AsyncScopesClient.java b/src/main/java/com/merge/api/resources/filestorage/scopes/AsyncScopesClient.java new file mode 100644 index 000000000..63ad71ff0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/scopes/AsyncScopesClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.scopes; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.filestorage.types.CommonModelScopeApi; +import java.util.concurrent.CompletableFuture; + +public class AsyncScopesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawScopesClient rawClient; + + public AsyncScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawScopesClient withRawResponse() { + return this.rawClient; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve() { + return this.rawClient.defaultScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.defaultScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve() { + return this.rawClient.linkedAccountScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return this.rawClient.linkedAccountScopesCreate(request).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/scopes/RawScopesClient.java b/src/main/java/com/merge/api/resources/filestorage/scopes/RawScopesClient.java new file mode 100644 index 000000000..0958c7a60 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/scopes/RawScopesClient.java @@ -0,0 +1,172 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.filestorage.types.CommonModelScopeApi; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawScopesClient { + protected final ClientOptions clientOptions; + + public RawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/scopes/ScopesClient.java b/src/main/java/com/merge/api/resources/filestorage/scopes/ScopesClient.java index 926bfe9d9..7d22cba2e 100644 --- a/src/main/java/com/merge/api/resources/filestorage/scopes/ScopesClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/scopes/ScopesClient.java @@ -3,118 +3,61 @@ */ package com.merge.api.resources.filestorage.scopes; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; import com.merge.api.resources.filestorage.types.CommonModelScopeApi; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ScopesClient { protected final ClientOptions clientOptions; + private final RawScopesClient rawClient; + public ScopesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawScopesClient withRawResponse() { + return this.rawClient; } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve() { - return defaultScopesRetrieve(null); + return this.rawClient.defaultScopesRetrieve().body(); } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/default-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.defaultScopesRetrieve(requestOptions).body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve() { - return linkedAccountScopesRetrieve(null); + return this.rawClient.linkedAccountScopesRetrieve().body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/linked-account-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).body(); } /** * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more */ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelScopeDeserializerRequest request) { - return linkedAccountScopesCreate(request, null); + return this.rawClient.linkedAccountScopesCreate(request).body(); } /** @@ -122,40 +65,6 @@ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelSco */ public CommonModelScopeApi linkedAccountScopesCreate( LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/linked-account-scopes") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/syncstatus/AsyncRawSyncStatusClient.java b/src/main/java/com/merge/api/resources/filestorage/syncstatus/AsyncRawSyncStatusClient.java new file mode 100644 index 000000000..cb9efaa1f --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/syncstatus/AsyncRawSyncStatusClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.filestorage.types.PaginatedSyncStatusList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawSyncStatusClient { + protected final ClientOptions clientOptions; + + public AsyncRawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedSyncStatusList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/syncstatus/AsyncSyncStatusClient.java b/src/main/java/com/merge/api/resources/filestorage/syncstatus/AsyncSyncStatusClient.java new file mode 100644 index 000000000..cb3d80191 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/syncstatus/AsyncSyncStatusClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.syncstatus; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.filestorage.types.PaginatedSyncStatusList; +import java.util.concurrent.CompletableFuture; + +public class AsyncSyncStatusClient { + protected final ClientOptions clientOptions; + + private final AsyncRawSyncStatusClient rawClient; + + public AsyncSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawSyncStatusClient withRawResponse() { + return this.rawClient; + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list(SyncStatusListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list( + SyncStatusListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/syncstatus/RawSyncStatusClient.java b/src/main/java/com/merge/api/resources/filestorage/syncstatus/RawSyncStatusClient.java new file mode 100644 index 000000000..41f046437 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/syncstatus/RawSyncStatusClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.filestorage.types.PaginatedSyncStatusList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawSyncStatusClient { + protected final ClientOptions clientOptions; + + public RawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/syncstatus/SyncStatusClient.java b/src/main/java/com/merge/api/resources/filestorage/syncstatus/SyncStatusClient.java index ad80aa4cb..93d203db8 100644 --- a/src/main/java/com/merge/api/resources/filestorage/syncstatus/SyncStatusClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/syncstatus/SyncStatusClient.java @@ -3,78 +3,46 @@ */ package com.merge.api.resources.filestorage.syncstatus; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.syncstatus.requests.SyncStatusListRequest; import com.merge.api.resources.filestorage.types.PaginatedSyncStatusList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class SyncStatusClient { protected final ClientOptions clientOptions; + private final RawSyncStatusClient rawClient; + public SyncStatusClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawSyncStatusClient withRawResponse() { + return this.rawClient; } /** * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list() { - return list(SyncStatusListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/sync-status"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/types/AccountToken.java b/src/main/java/com/merge/api/resources/filestorage/types/AccountToken.java index d275c147f..4a430b825 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/AccountToken.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/AccountToken.java @@ -23,12 +23,15 @@ public final class AccountToken { private final AccountIntegration integration; + private final String id; + private final Map additionalProperties; private AccountToken( - String accountToken, AccountIntegration integration, Map additionalProperties) { + String accountToken, AccountIntegration integration, String id, Map additionalProperties) { this.accountToken = accountToken; this.integration = integration; + this.id = id; this.additionalProperties = additionalProperties; } @@ -42,6 +45,11 @@ public AccountIntegration getIntegration() { return integration; } + @JsonProperty("id") + public String getId() { + return id; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -54,12 +62,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(AccountToken other) { - return accountToken.equals(other.accountToken) && integration.equals(other.integration); + return accountToken.equals(other.accountToken) && integration.equals(other.integration) && id.equals(other.id); } @java.lang.Override public int hashCode() { - return Objects.hash(this.accountToken, this.integration); + return Objects.hash(this.accountToken, this.integration, this.id); } @java.lang.Override @@ -78,7 +86,11 @@ public interface AccountTokenStage { } public interface IntegrationStage { - _FinalStage integration(@NotNull AccountIntegration integration); + IdStage integration(@NotNull AccountIntegration integration); + } + + public interface IdStage { + _FinalStage id(@NotNull String id); } public interface _FinalStage { @@ -86,11 +98,13 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AccountTokenStage, IntegrationStage, _FinalStage { + public static final class Builder implements AccountTokenStage, IntegrationStage, IdStage, _FinalStage { private String accountToken; private AccountIntegration integration; + private String id; + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -100,6 +114,7 @@ private Builder() {} public Builder from(AccountToken other) { accountToken(other.getAccountToken()); integration(other.getIntegration()); + id(other.getId()); return this; } @@ -112,14 +127,21 @@ public IntegrationStage accountToken(@NotNull String accountToken) { @java.lang.Override @JsonSetter("integration") - public _FinalStage integration(@NotNull AccountIntegration integration) { + public IdStage integration(@NotNull AccountIntegration integration) { this.integration = integration; return this; } + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = id; + return this; + } + @java.lang.Override public AccountToken build() { - return new AccountToken(accountToken, integration, additionalProperties); + return new AccountToken(accountToken, integration, id, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/filestorage/types/AuditLogEvent.java b/src/main/java/com/merge/api/resources/filestorage/types/AuditLogEvent.java index a8a631241..5b060c30f 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/AuditLogEvent.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/AuditLogEvent.java @@ -28,11 +28,11 @@ public final class AuditLogEvent { private final Optional userEmail; - private final AuditLogEventRole role; + private final RoleEnum role; private final String ipAddress; - private final AuditLogEventEventType eventType; + private final EventTypeEnum eventType; private final String eventDescription; @@ -44,9 +44,9 @@ private AuditLogEvent( Optional id, Optional userName, Optional userEmail, - AuditLogEventRole role, + RoleEnum role, String ipAddress, - AuditLogEventEventType eventType, + EventTypeEnum eventType, String eventDescription, Optional createdAt, Map additionalProperties) { @@ -94,7 +94,7 @@ public Optional getUserEmail() { * */ @JsonProperty("role") - public AuditLogEventRole getRole() { + public RoleEnum getRole() { return role; } @@ -115,6 +115,7 @@ public String getIpAddress() { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -150,7 +151,7 @@ public String getIpAddress() { * */ @JsonProperty("event_type") - public AuditLogEventEventType getEventType() { + public EventTypeEnum getEventType() { return eventType; } @@ -209,7 +210,7 @@ public static RoleStage builder() { } public interface RoleStage { - IpAddressStage role(@NotNull AuditLogEventRole role); + IpAddressStage role(@NotNull RoleEnum role); Builder from(AuditLogEvent other); } @@ -219,7 +220,7 @@ public interface IpAddressStage { } public interface EventTypeStage { - EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType); + EventDescriptionStage eventType(@NotNull EventTypeEnum eventType); } public interface EventDescriptionStage { @@ -249,11 +250,11 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements RoleStage, IpAddressStage, EventTypeStage, EventDescriptionStage, _FinalStage { - private AuditLogEventRole role; + private RoleEnum role; private String ipAddress; - private AuditLogEventEventType eventType; + private EventTypeEnum eventType; private String eventDescription; @@ -297,7 +298,7 @@ public Builder from(AuditLogEvent other) { */ @java.lang.Override @JsonSetter("role") - public IpAddressStage role(@NotNull AuditLogEventRole role) { + public IpAddressStage role(@NotNull RoleEnum role) { this.role = role; return this; } @@ -321,6 +322,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -358,7 +360,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { */ @java.lang.Override @JsonSetter("event_type") - public EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType) { + public EventDescriptionStage eventType(@NotNull EventTypeEnum eventType) { this.eventType = eventType; return this; } diff --git a/src/main/java/com/merge/api/resources/filestorage/types/AuditLogEventEventType.java b/src/main/java/com/merge/api/resources/filestorage/types/AuditLogEventEventType.java deleted file mode 100644 index 9e60a9b63..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/types/AuditLogEventEventType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventEventType.Deserializer.class) -public final class AuditLogEventEventType { - private final Object value; - - private final int type; - - private AuditLogEventEventType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EventTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventEventType && equalTo((AuditLogEventEventType) other); - } - - private boolean equalTo(AuditLogEventEventType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventEventType of(EventTypeEnum value) { - return new AuditLogEventEventType(value, 0); - } - - public static AuditLogEventEventType of(String value) { - return new AuditLogEventEventType(value, 1); - } - - public interface Visitor { - T visit(EventTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventEventType.class); - } - - @java.lang.Override - public AuditLogEventEventType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EventTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/AuditLogEventRole.java b/src/main/java/com/merge/api/resources/filestorage/types/AuditLogEventRole.java deleted file mode 100644 index c4290414f..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/types/AuditLogEventRole.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventRole.Deserializer.class) -public final class AuditLogEventRole { - private final Object value; - - private final int type; - - private AuditLogEventRole(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RoleEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventRole && equalTo((AuditLogEventRole) other); - } - - private boolean equalTo(AuditLogEventRole other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventRole of(RoleEnum value) { - return new AuditLogEventRole(value, 0); - } - - public static AuditLogEventRole of(String value) { - return new AuditLogEventRole(value, 1); - } - - public interface Visitor { - T visit(RoleEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventRole.class); - } - - @java.lang.Override - public AuditLogEventRole deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RoleEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/DownloadRequestMeta.java b/src/main/java/com/merge/api/resources/filestorage/types/DownloadRequestMeta.java new file mode 100644 index 000000000..cb1e38cfb --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/types/DownloadRequestMeta.java @@ -0,0 +1,233 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = DownloadRequestMeta.Builder.class) +public final class DownloadRequestMeta { + private final String id; + + private final String url; + + private final String method; + + private final Map headers; + + private final Map body; + + private final Map additionalProperties; + + private DownloadRequestMeta( + String id, + String url, + String method, + Map headers, + Map body, + Map additionalProperties) { + this.id = id; + this.url = url; + this.method = method; + this.headers = headers; + this.body = body; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("url") + public String getUrl() { + return url; + } + + @JsonProperty("method") + public String getMethod() { + return method; + } + + @JsonProperty("headers") + public Map getHeaders() { + return headers; + } + + @JsonProperty("body") + public Map getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DownloadRequestMeta && equalTo((DownloadRequestMeta) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(DownloadRequestMeta other) { + return id.equals(other.id) + && url.equals(other.url) + && method.equals(other.method) + && headers.equals(other.headers) + && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.url, this.method, this.headers, this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + UrlStage id(@NotNull String id); + + Builder from(DownloadRequestMeta other); + } + + public interface UrlStage { + MethodStage url(@NotNull String url); + } + + public interface MethodStage { + _FinalStage method(@NotNull String method); + } + + public interface _FinalStage { + DownloadRequestMeta build(); + + _FinalStage headers(Map headers); + + _FinalStage putAllHeaders(Map headers); + + _FinalStage headers(String key, JsonNode value); + + _FinalStage body(Map body); + + _FinalStage putAllBody(Map body); + + _FinalStage body(String key, JsonNode value); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, UrlStage, MethodStage, _FinalStage { + private String id; + + private String url; + + private String method; + + private Map body = new LinkedHashMap<>(); + + private Map headers = new LinkedHashMap<>(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(DownloadRequestMeta other) { + id(other.getId()); + url(other.getUrl()); + method(other.getMethod()); + headers(other.getHeaders()); + body(other.getBody()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public UrlStage id(@NotNull String id) { + this.id = id; + return this; + } + + @java.lang.Override + @JsonSetter("url") + public MethodStage url(@NotNull String url) { + this.url = url; + return this; + } + + @java.lang.Override + @JsonSetter("method") + public _FinalStage method(@NotNull String method) { + this.method = method; + return this; + } + + @java.lang.Override + public _FinalStage body(String key, JsonNode value) { + this.body.put(key, value); + return this; + } + + @java.lang.Override + public _FinalStage putAllBody(Map body) { + this.body.putAll(body); + return this; + } + + @java.lang.Override + @JsonSetter(value = "body", nulls = Nulls.SKIP) + public _FinalStage body(Map body) { + this.body.clear(); + this.body.putAll(body); + return this; + } + + @java.lang.Override + public _FinalStage headers(String key, JsonNode value) { + this.headers.put(key, value); + return this; + } + + @java.lang.Override + public _FinalStage putAllHeaders(Map headers) { + this.headers.putAll(headers); + return this; + } + + @java.lang.Override + @JsonSetter(value = "headers", nulls = Nulls.SKIP) + public _FinalStage headers(Map headers) { + this.headers.clear(); + this.headers.putAll(headers); + return this; + } + + @java.lang.Override + public DownloadRequestMeta build() { + return new DownloadRequestMeta(id, url, method, headers, body, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/EventTypeEnum.java b/src/main/java/com/merge/api/resources/filestorage/types/EventTypeEnum.java index b199074a0..7a94ee492 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/EventTypeEnum.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/EventTypeEnum.java @@ -24,6 +24,8 @@ public enum EventTypeEnum { DELETED_LINKED_ACCOUNT("DELETED_LINKED_ACCOUNT"), + DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT("DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT"), + CREATED_DESTINATION("CREATED_DESTINATION"), DELETED_DESTINATION("DELETED_DESTINATION"), diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FileDrive.java b/src/main/java/com/merge/api/resources/filestorage/types/FileDrive.java index 65cd761c1..76cbab4ee 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FileDrive.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FileDrive.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FileDrive deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FileDrive deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FileFolder.java b/src/main/java/com/merge/api/resources/filestorage/types/FileFolder.java index db27a890b..a166e26aa 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FileFolder.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FileFolder.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FileFolder deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FileFolder deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FilePermissions.java b/src/main/java/com/merge/api/resources/filestorage/types/FilePermissions.java index 09f4e5f6c..306d070b5 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FilePermissions.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FilePermissions.java @@ -31,11 +31,12 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); } else if (this.type == 1) { - return visitor.visit((PermissionRequest) this.value); + return visitor.visit((Permission) this.value); } else if (this.type == 2) { return visitor.visit((List) this.value); } @@ -66,7 +67,7 @@ public static FilePermissions of(String value) { return new FilePermissions(value, 0); } - public static FilePermissions of(PermissionRequest value) { + public static FilePermissions of(Permission value) { return new FilePermissions(value, 1); } @@ -77,7 +78,7 @@ public static FilePermissions of(List value) { public interface Visitor { T visit(String value); - T visit(PermissionRequest value); + T visit(Permission value); T visit(List value); } @@ -88,14 +89,14 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FilePermissions deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FilePermissions deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); } catch (IllegalArgumentException e) { } try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PermissionRequest.class)); + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Permission.class)); } catch (IllegalArgumentException e) { } try { diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FilePermissionsItem.java b/src/main/java/com/merge/api/resources/filestorage/types/FilePermissionsItem.java index eb2f9519c..e2bc1831c 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FilePermissionsItem.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FilePermissionsItem.java @@ -29,11 +29,12 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); } else if (this.type == 1) { - return visitor.visit((PermissionRequest) this.value); + return visitor.visit((Permission) this.value); } throw new IllegalStateException("Failed to visit value. This should never happen."); } @@ -62,14 +63,14 @@ public static FilePermissionsItem of(String value) { return new FilePermissionsItem(value, 0); } - public static FilePermissionsItem of(PermissionRequest value) { + public static FilePermissionsItem of(Permission value) { return new FilePermissionsItem(value, 1); } public interface Visitor { T visit(String value); - T visit(PermissionRequest value); + T visit(Permission value); } static final class Deserializer extends StdDeserializer { @@ -78,14 +79,14 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FilePermissionsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FilePermissionsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); } catch (IllegalArgumentException e) { } try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PermissionRequest.class)); + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Permission.class)); } catch (IllegalArgumentException e) { } throw new JsonParseException(p, "Failed to deserialize"); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FileRequestDrive.java b/src/main/java/com/merge/api/resources/filestorage/types/FileRequestDrive.java index 73b1cf4ac..cff07a6cb 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FileRequestDrive.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FileRequestDrive.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FileRequestDrive deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FileRequestDrive deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FileRequestFolder.java b/src/main/java/com/merge/api/resources/filestorage/types/FileRequestFolder.java index 71ff18f25..370fb090b 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FileRequestFolder.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FileRequestFolder.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FileRequestFolder deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FileRequestFolder deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FileRequestPermissions.java b/src/main/java/com/merge/api/resources/filestorage/types/FileRequestPermissions.java index cc36e0eeb..4328c3180 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FileRequestPermissions.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FileRequestPermissions.java @@ -31,6 +31,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -88,7 +89,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public FileRequestPermissions deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FileRequestPermissions deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FileRequestPermissionsItem.java b/src/main/java/com/merge/api/resources/filestorage/types/FileRequestPermissionsItem.java index 0e281743b..7ee67cf13 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FileRequestPermissionsItem.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FileRequestPermissionsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FolderDrive deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FolderDrive deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FolderParentFolder.java b/src/main/java/com/merge/api/resources/filestorage/types/FolderParentFolder.java index 5d5951072..82f0dae7a 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FolderParentFolder.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FolderParentFolder.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FolderParentFolder deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FolderParentFolder deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FolderPermissions.java b/src/main/java/com/merge/api/resources/filestorage/types/FolderPermissions.java index e218bd1fb..fa6be9b59 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FolderPermissions.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FolderPermissions.java @@ -31,11 +31,12 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); } else if (this.type == 1) { - return visitor.visit((PermissionRequest) this.value); + return visitor.visit((Permission) this.value); } else if (this.type == 2) { return visitor.visit((List) this.value); } @@ -66,7 +67,7 @@ public static FolderPermissions of(String value) { return new FolderPermissions(value, 0); } - public static FolderPermissions of(PermissionRequest value) { + public static FolderPermissions of(Permission value) { return new FolderPermissions(value, 1); } @@ -77,7 +78,7 @@ public static FolderPermissions of(List value) { public interface Visitor { T visit(String value); - T visit(PermissionRequest value); + T visit(Permission value); T visit(List value); } @@ -88,14 +89,14 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FolderPermissions deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FolderPermissions deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); } catch (IllegalArgumentException e) { } try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PermissionRequest.class)); + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Permission.class)); } catch (IllegalArgumentException e) { } try { diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FolderPermissionsItem.java b/src/main/java/com/merge/api/resources/filestorage/types/FolderPermissionsItem.java index 29d78fa26..0c747df59 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FolderPermissionsItem.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FolderPermissionsItem.java @@ -29,11 +29,12 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); } else if (this.type == 1) { - return visitor.visit((PermissionRequest) this.value); + return visitor.visit((Permission) this.value); } throw new IllegalStateException("Failed to visit value. This should never happen."); } @@ -62,14 +63,14 @@ public static FolderPermissionsItem of(String value) { return new FolderPermissionsItem(value, 0); } - public static FolderPermissionsItem of(PermissionRequest value) { + public static FolderPermissionsItem of(Permission value) { return new FolderPermissionsItem(value, 1); } public interface Visitor { T visit(String value); - T visit(PermissionRequest value); + T visit(Permission value); } static final class Deserializer extends StdDeserializer { @@ -78,14 +79,14 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FolderPermissionsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FolderPermissionsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); } catch (IllegalArgumentException e) { } try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PermissionRequest.class)); + return of(ObjectMappers.JSON_MAPPER.convertValue(value, Permission.class)); } catch (IllegalArgumentException e) { } throw new JsonParseException(p, "Failed to deserialize"); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FolderRequestDrive.java b/src/main/java/com/merge/api/resources/filestorage/types/FolderRequestDrive.java index 487981030..c3ab9cfe0 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FolderRequestDrive.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FolderRequestDrive.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public FolderRequestDrive deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public FolderRequestDrive deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/FolderRequestParentFolder.java b/src/main/java/com/merge/api/resources/filestorage/types/FolderRequestParentFolder.java index c70e803bd..f02e4aec1 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/FolderRequestParentFolder.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/FolderRequestParentFolder.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -88,7 +89,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public GroupChildGroupsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public GroupChildGroupsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/Issue.java b/src/main/java/com/merge/api/resources/filestorage/types/Issue.java index 1dcd8706f..475845806 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/Issue.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/Issue.java @@ -26,7 +26,7 @@ public final class Issue { private final Optional id; - private final Optional status; + private final Optional status; private final String errorDescription; @@ -44,7 +44,7 @@ public final class Issue { private Issue( Optional id, - Optional status, + Optional status, String errorDescription, Optional> endUser, Optional firstIncidentTime, @@ -76,7 +76,7 @@ public Optional getId() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -167,9 +167,9 @@ public interface _FinalStage { _FinalStage id(String id); - _FinalStage status(Optional status); + _FinalStage status(Optional status); - _FinalStage status(IssueStatus status); + _FinalStage status(IssueStatusEnum status); _FinalStage endUser(Optional> endUser); @@ -206,7 +206,7 @@ public static final class Builder implements ErrorDescriptionStage, _FinalStage private Optional> endUser = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional id = Optional.empty(); @@ -309,14 +309,14 @@ public _FinalStage endUser(Optional> endUser) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage status(IssueStatus status) { + public _FinalStage status(IssueStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @java.lang.Override @JsonSetter(value = "status", nulls = Nulls.SKIP) - public _FinalStage status(Optional status) { + public _FinalStage status(Optional status) { this.status = status; return this; } diff --git a/src/main/java/com/merge/api/resources/filestorage/types/IssueStatus.java b/src/main/java/com/merge/api/resources/filestorage/types/IssueStatus.java deleted file mode 100644 index 80fb54a0b..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/types/IssueStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = IssueStatus.Deserializer.class) -public final class IssueStatus { - private final Object value; - - private final int type; - - private IssueStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((IssueStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IssueStatus && equalTo((IssueStatus) other); - } - - private boolean equalTo(IssueStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static IssueStatus of(IssueStatusEnum value) { - return new IssueStatus(value, 0); - } - - public static IssueStatus of(String value) { - return new IssueStatus(value, 1); - } - - public interface Visitor { - T visit(IssueStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(IssueStatus.class); - } - - @java.lang.Override - public IssueStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, IssueStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/LastSyncResultEnum.java b/src/main/java/com/merge/api/resources/filestorage/types/LastSyncResultEnum.java new file mode 100644 index 000000000..c678a622d --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/types/LastSyncResultEnum.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum LastSyncResultEnum { + SYNCING("SYNCING"), + + DONE("DONE"), + + FAILED("FAILED"), + + DISABLED("DISABLED"), + + PAUSED("PAUSED"), + + PARTIALLY_SYNCED("PARTIALLY_SYNCED"); + + private final String value; + + LastSyncResultEnum(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/MultipartFormFieldRequest.java b/src/main/java/com/merge/api/resources/filestorage/types/MultipartFormFieldRequest.java index b982e3d76..8324a786b 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/MultipartFormFieldRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/MultipartFormFieldRequest.java @@ -25,7 +25,7 @@ public final class MultipartFormFieldRequest { private final String data; - private final Optional encoding; + private final Optional encoding; private final Optional fileName; @@ -36,7 +36,7 @@ public final class MultipartFormFieldRequest { private MultipartFormFieldRequest( String name, String data, - Optional encoding, + Optional encoding, Optional fileName, Optional contentType, Map additionalProperties) { @@ -73,7 +73,7 @@ public String getData() { * */ @JsonProperty("encoding") - public Optional getEncoding() { + public Optional getEncoding() { return encoding; } @@ -139,9 +139,9 @@ public interface DataStage { public interface _FinalStage { MultipartFormFieldRequest build(); - _FinalStage encoding(Optional encoding); + _FinalStage encoding(Optional encoding); - _FinalStage encoding(MultipartFormFieldRequestEncoding encoding); + _FinalStage encoding(EncodingEnum encoding); _FinalStage fileName(Optional fileName); @@ -162,7 +162,7 @@ public static final class Builder implements NameStage, DataStage, _FinalStage { private Optional fileName = Optional.empty(); - private Optional encoding = Optional.empty(); + private Optional encoding = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -245,14 +245,14 @@ public _FinalStage fileName(Optional fileName) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage encoding(MultipartFormFieldRequestEncoding encoding) { + public _FinalStage encoding(EncodingEnum encoding) { this.encoding = Optional.ofNullable(encoding); return this; } @java.lang.Override @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { + public _FinalStage encoding(Optional encoding) { this.encoding = encoding; return this; } diff --git a/src/main/java/com/merge/api/resources/filestorage/types/MultipartFormFieldRequestEncoding.java b/src/main/java/com/merge/api/resources/filestorage/types/MultipartFormFieldRequestEncoding.java deleted file mode 100644 index 87b53edea..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/types/MultipartFormFieldRequestEncoding.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = MultipartFormFieldRequestEncoding.Deserializer.class) -public final class MultipartFormFieldRequestEncoding { - private final Object value; - - private final int type; - - private MultipartFormFieldRequestEncoding(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EncodingEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MultipartFormFieldRequestEncoding && equalTo((MultipartFormFieldRequestEncoding) other); - } - - private boolean equalTo(MultipartFormFieldRequestEncoding other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static MultipartFormFieldRequestEncoding of(EncodingEnum value) { - return new MultipartFormFieldRequestEncoding(value, 0); - } - - public static MultipartFormFieldRequestEncoding of(String value) { - return new MultipartFormFieldRequestEncoding(value, 1); - } - - public interface Visitor { - T visit(EncodingEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(MultipartFormFieldRequestEncoding.class); - } - - @java.lang.Override - public MultipartFormFieldRequestEncoding deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EncodingEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/PaginatedDownloadRequestMetaList.java b/src/main/java/com/merge/api/resources/filestorage/types/PaginatedDownloadRequestMetaList.java new file mode 100644 index 000000000..ecf19289d --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/types/PaginatedDownloadRequestMetaList.java @@ -0,0 +1,144 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = PaginatedDownloadRequestMetaList.Builder.class) +public final class PaginatedDownloadRequestMetaList { + private final Optional next; + + private final Optional previous; + + private final Optional> results; + + private final Map additionalProperties; + + private PaginatedDownloadRequestMetaList( + Optional next, + Optional previous, + Optional> results, + Map additionalProperties) { + this.next = next; + this.previous = previous; + this.results = results; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("next") + public Optional getNext() { + return next; + } + + @JsonProperty("previous") + public Optional getPrevious() { + return previous; + } + + @JsonProperty("results") + public Optional> getResults() { + return results; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PaginatedDownloadRequestMetaList && equalTo((PaginatedDownloadRequestMetaList) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(PaginatedDownloadRequestMetaList other) { + return next.equals(other.next) && previous.equals(other.previous) && results.equals(other.results); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.next, this.previous, this.results); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional next = Optional.empty(); + + private Optional previous = Optional.empty(); + + private Optional> results = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(PaginatedDownloadRequestMetaList other) { + next(other.getNext()); + previous(other.getPrevious()); + results(other.getResults()); + return this; + } + + @JsonSetter(value = "next", nulls = Nulls.SKIP) + public Builder next(Optional next) { + this.next = next; + return this; + } + + public Builder next(String next) { + this.next = Optional.ofNullable(next); + return this; + } + + @JsonSetter(value = "previous", nulls = Nulls.SKIP) + public Builder previous(Optional previous) { + this.previous = previous; + return this; + } + + public Builder previous(String previous) { + this.previous = Optional.ofNullable(previous); + return this; + } + + @JsonSetter(value = "results", nulls = Nulls.SKIP) + public Builder results(Optional> results) { + this.results = results; + return this; + } + + public Builder results(List results) { + this.results = Optional.ofNullable(results); + return this; + } + + public PaginatedDownloadRequestMetaList build() { + return new PaginatedDownloadRequestMetaList(next, previous, results, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/Permission.java b/src/main/java/com/merge/api/resources/filestorage/types/Permission.java index add248c84..8eb7e8d65 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/Permission.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/Permission.java @@ -34,9 +34,9 @@ public final class Permission { private final Optional group; - private final Optional type; + private final Optional type; - private final Optional>> roles; + private final Optional> roles; private final Map additionalProperties; @@ -47,8 +47,8 @@ private Permission( Optional modifiedAt, Optional user, Optional group, - Optional type, - Optional>> roles, + Optional type, + Optional> roles, Map additionalProperties) { this.id = id; this.remoteId = remoteId; @@ -116,7 +116,7 @@ public Optional getGroup() { * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -124,7 +124,7 @@ public Optional getType() { * @return The permissions that the user or group has for the File or Folder. It is possible for a user or group to have multiple roles, such as viewing & uploading. Possible values include: READ, WRITE, OWNER. In cases where there is no clear mapping, the original value passed through will be returned. */ @JsonProperty("roles") - public Optional>> getRoles() { + public Optional> getRoles() { return roles; } @@ -179,9 +179,9 @@ public static final class Builder { private Optional group = Optional.empty(); - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); - private Optional>> roles = Optional.empty(); + private Optional> roles = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -267,23 +267,23 @@ public Builder group(PermissionGroup group) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(PermissionType type) { + public Builder type(TypeEnum type) { this.type = Optional.ofNullable(type); return this; } @JsonSetter(value = "roles", nulls = Nulls.SKIP) - public Builder roles(Optional>> roles) { + public Builder roles(Optional> roles) { this.roles = roles; return this; } - public Builder roles(List> roles) { + public Builder roles(List roles) { this.roles = Optional.ofNullable(roles); return this; } diff --git a/src/main/java/com/merge/api/resources/filestorage/types/PermissionGroup.java b/src/main/java/com/merge/api/resources/filestorage/types/PermissionGroup.java index b6f6439d1..63e7587a3 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/PermissionGroup.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/PermissionGroup.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PermissionGroup deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PermissionGroup deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequest.java b/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequest.java index aae51beb4..8a91a30aa 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequest.java @@ -28,9 +28,9 @@ public final class PermissionRequest { private final Optional group; - private final Optional type; + private final Optional type; - private final Optional>> roles; + private final Optional> roles; private final Optional> integrationParams; @@ -42,8 +42,8 @@ private PermissionRequest( Optional remoteId, Optional user, Optional group, - Optional type, - Optional>> roles, + Optional type, + Optional> roles, Optional> integrationParams, Optional> linkedAccountParams, Map additionalProperties) { @@ -91,7 +91,7 @@ public Optional getGroup() { * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -99,7 +99,7 @@ public Optional getType() { * @return The permissions that the user or group has for the File or Folder. It is possible for a user or group to have multiple roles, such as viewing & uploading. Possible values include: READ, WRITE, OWNER. In cases where there is no clear mapping, the original value passed through will be returned. */ @JsonProperty("roles") - public Optional>> getRoles() { + public Optional> getRoles() { return roles; } @@ -163,9 +163,9 @@ public static final class Builder { private Optional group = Optional.empty(); - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); - private Optional>> roles = Optional.empty(); + private Optional> roles = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -221,23 +221,23 @@ public Builder group(PermissionRequestGroup group) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(PermissionRequestType type) { + public Builder type(TypeEnum type) { this.type = Optional.ofNullable(type); return this; } @JsonSetter(value = "roles", nulls = Nulls.SKIP) - public Builder roles(Optional>> roles) { + public Builder roles(Optional> roles) { this.roles = roles; return this; } - public Builder roles(List> roles) { + public Builder roles(List roles) { this.roles = Optional.ofNullable(roles); return this; } diff --git a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestGroup.java b/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestGroup.java index 61bd7d834..f870be69a 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestGroup.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestGroup.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public PermissionRequestGroup deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PermissionRequestGroup deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestRolesItem.java b/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestRolesItem.java deleted file mode 100644 index 2d423b8e8..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestRolesItem.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PermissionRequestRolesItem.Deserializer.class) -public final class PermissionRequestRolesItem { - private final Object value; - - private final int type; - - private PermissionRequestRolesItem(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RolesEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PermissionRequestRolesItem && equalTo((PermissionRequestRolesItem) other); - } - - private boolean equalTo(PermissionRequestRolesItem other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PermissionRequestRolesItem of(RolesEnum value) { - return new PermissionRequestRolesItem(value, 0); - } - - public static PermissionRequestRolesItem of(String value) { - return new PermissionRequestRolesItem(value, 1); - } - - public interface Visitor { - T visit(RolesEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PermissionRequestRolesItem.class); - } - - @java.lang.Override - public PermissionRequestRolesItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RolesEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestType.java b/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestType.java deleted file mode 100644 index 37481dcf0..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PermissionRequestType.Deserializer.class) -public final class PermissionRequestType { - private final Object value; - - private final int type; - - private PermissionRequestType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PermissionRequestType && equalTo((PermissionRequestType) other); - } - - private boolean equalTo(PermissionRequestType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PermissionRequestType of(TypeEnum value) { - return new PermissionRequestType(value, 0); - } - - public static PermissionRequestType of(String value) { - return new PermissionRequestType(value, 1); - } - - public interface Visitor { - T visit(TypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PermissionRequestType.class); - } - - @java.lang.Override - public PermissionRequestType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestUser.java b/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestUser.java index c87ae8ca2..8a4f1488a 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestUser.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/PermissionRequestUser.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PermissionRequestUser deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PermissionRequestUser deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRolesItem.java b/src/main/java/com/merge/api/resources/filestorage/types/PermissionRolesItem.java deleted file mode 100644 index 749ea9ca9..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/types/PermissionRolesItem.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PermissionRolesItem.Deserializer.class) -public final class PermissionRolesItem { - private final Object value; - - private final int type; - - private PermissionRolesItem(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RolesEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PermissionRolesItem && equalTo((PermissionRolesItem) other); - } - - private boolean equalTo(PermissionRolesItem other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PermissionRolesItem of(RolesEnum value) { - return new PermissionRolesItem(value, 0); - } - - public static PermissionRolesItem of(String value) { - return new PermissionRolesItem(value, 1); - } - - public interface Visitor { - T visit(RolesEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PermissionRolesItem.class); - } - - @java.lang.Override - public PermissionRolesItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RolesEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/PermissionType.java b/src/main/java/com/merge/api/resources/filestorage/types/PermissionType.java deleted file mode 100644 index 08cc374f6..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/types/PermissionType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PermissionType.Deserializer.class) -public final class PermissionType { - private final Object value; - - private final int type; - - private PermissionType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PermissionType && equalTo((PermissionType) other); - } - - private boolean equalTo(PermissionType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PermissionType of(TypeEnum value) { - return new PermissionType(value, 0); - } - - public static PermissionType of(String value) { - return new PermissionType(value, 1); - } - - public interface Visitor { - T visit(TypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PermissionType.class); - } - - @java.lang.Override - public PermissionType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/PermissionUser.java b/src/main/java/com/merge/api/resources/filestorage/types/PermissionUser.java index 1594302b2..59af8d32e 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/PermissionUser.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/PermissionUser.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public PermissionUser deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public PermissionUser deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/RemoteFieldApiCoverage.java b/src/main/java/com/merge/api/resources/filestorage/types/RemoteFieldApiCoverage.java index 759fd9ac2..e224bac0f 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/RemoteFieldApiCoverage.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/RemoteFieldApiCoverage.java @@ -28,6 +28,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((int) this.value); @@ -77,7 +78,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); if (value instanceof Integer) { return of((Integer) value); diff --git a/src/main/java/com/merge/api/resources/filestorage/types/StatusFd5Enum.java b/src/main/java/com/merge/api/resources/filestorage/types/StatusFd5Enum.java new file mode 100644 index 000000000..822015c5e --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/types/StatusFd5Enum.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum StatusFd5Enum { + SYNCING("SYNCING"), + + DONE("DONE"), + + FAILED("FAILED"), + + DISABLED("DISABLED"), + + PAUSED("PAUSED"), + + PARTIALLY_SYNCED("PARTIALLY_SYNCED"); + + private final String value; + + StatusFd5Enum(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/types/SyncStatus.java b/src/main/java/com/merge/api/resources/filestorage/types/SyncStatus.java index a3733ef3c..e4972a963 100644 --- a/src/main/java/com/merge/api/resources/filestorage/types/SyncStatus.java +++ b/src/main/java/com/merge/api/resources/filestorage/types/SyncStatus.java @@ -30,7 +30,11 @@ public final class SyncStatus { private final Optional nextSyncStart; - private final SyncStatusStatusEnum status; + private final Optional lastSyncResult; + + private final Optional lastSyncFinished; + + private final StatusFd5Enum status; private final boolean isInitialSync; @@ -43,7 +47,9 @@ private SyncStatus( String modelId, Optional lastSyncStart, Optional nextSyncStart, - SyncStatusStatusEnum status, + Optional lastSyncResult, + Optional lastSyncFinished, + StatusFd5Enum status, boolean isInitialSync, Optional selectiveSyncConfigurationsUsage, Map additionalProperties) { @@ -51,6 +57,8 @@ private SyncStatus( this.modelId = modelId; this.lastSyncStart = lastSyncStart; this.nextSyncStart = nextSyncStart; + this.lastSyncResult = lastSyncResult; + this.lastSyncFinished = lastSyncFinished; this.status = status; this.isInitialSync = isInitialSync; this.selectiveSyncConfigurationsUsage = selectiveSyncConfigurationsUsage; @@ -77,8 +85,18 @@ public Optional getNextSyncStart() { return nextSyncStart; } + @JsonProperty("last_sync_result") + public Optional getLastSyncResult() { + return lastSyncResult; + } + + @JsonProperty("last_sync_finished") + public Optional getLastSyncFinished() { + return lastSyncFinished; + } + @JsonProperty("status") - public SyncStatusStatusEnum getStatus() { + public StatusFd5Enum getStatus() { return status; } @@ -108,6 +126,8 @@ private boolean equalTo(SyncStatus other) { && modelId.equals(other.modelId) && lastSyncStart.equals(other.lastSyncStart) && nextSyncStart.equals(other.nextSyncStart) + && lastSyncResult.equals(other.lastSyncResult) + && lastSyncFinished.equals(other.lastSyncFinished) && status.equals(other.status) && isInitialSync == other.isInitialSync && selectiveSyncConfigurationsUsage.equals(other.selectiveSyncConfigurationsUsage); @@ -120,6 +140,8 @@ public int hashCode() { this.modelId, this.lastSyncStart, this.nextSyncStart, + this.lastSyncResult, + this.lastSyncFinished, this.status, this.isInitialSync, this.selectiveSyncConfigurationsUsage); @@ -145,7 +167,7 @@ public interface ModelIdStage { } public interface StatusStage { - IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status); + IsInitialSyncStage status(@NotNull StatusFd5Enum status); } public interface IsInitialSyncStage { @@ -163,6 +185,14 @@ public interface _FinalStage { _FinalStage nextSyncStart(OffsetDateTime nextSyncStart); + _FinalStage lastSyncResult(Optional lastSyncResult); + + _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult); + + _FinalStage lastSyncFinished(Optional lastSyncFinished); + + _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished); + _FinalStage selectiveSyncConfigurationsUsage( Optional selectiveSyncConfigurationsUsage); @@ -177,12 +207,16 @@ public static final class Builder private String modelId; - private SyncStatusStatusEnum status; + private StatusFd5Enum status; private boolean isInitialSync; private Optional selectiveSyncConfigurationsUsage = Optional.empty(); + private Optional lastSyncFinished = Optional.empty(); + + private Optional lastSyncResult = Optional.empty(); + private Optional nextSyncStart = Optional.empty(); private Optional lastSyncStart = Optional.empty(); @@ -198,6 +232,8 @@ public Builder from(SyncStatus other) { modelId(other.getModelId()); lastSyncStart(other.getLastSyncStart()); nextSyncStart(other.getNextSyncStart()); + lastSyncResult(other.getLastSyncResult()); + lastSyncFinished(other.getLastSyncFinished()); status(other.getStatus()); isInitialSync(other.getIsInitialSync()); selectiveSyncConfigurationsUsage(other.getSelectiveSyncConfigurationsUsage()); @@ -220,7 +256,7 @@ public StatusStage modelId(@NotNull String modelId) { @java.lang.Override @JsonSetter("status") - public IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status) { + public IsInitialSyncStage status(@NotNull StatusFd5Enum status) { this.status = status; return this; } @@ -247,6 +283,32 @@ public _FinalStage selectiveSyncConfigurationsUsage( return this; } + @java.lang.Override + public _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished) { + this.lastSyncFinished = Optional.ofNullable(lastSyncFinished); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_finished", nulls = Nulls.SKIP) + public _FinalStage lastSyncFinished(Optional lastSyncFinished) { + this.lastSyncFinished = lastSyncFinished; + return this; + } + + @java.lang.Override + public _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult) { + this.lastSyncResult = Optional.ofNullable(lastSyncResult); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_result", nulls = Nulls.SKIP) + public _FinalStage lastSyncResult(Optional lastSyncResult) { + this.lastSyncResult = lastSyncResult; + return this; + } + @java.lang.Override public _FinalStage nextSyncStart(OffsetDateTime nextSyncStart) { this.nextSyncStart = Optional.ofNullable(nextSyncStart); @@ -280,6 +342,8 @@ public SyncStatus build() { modelId, lastSyncStart, nextSyncStart, + lastSyncResult, + lastSyncFinished, status, isInitialSync, selectiveSyncConfigurationsUsage, diff --git a/src/main/java/com/merge/api/resources/filestorage/types/SyncStatusStatusEnum.java b/src/main/java/com/merge/api/resources/filestorage/types/SyncStatusStatusEnum.java deleted file mode 100644 index 9e5dd7a11..000000000 --- a/src/main/java/com/merge/api/resources/filestorage/types/SyncStatusStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.filestorage.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SyncStatusStatusEnum { - SYNCING("SYNCING"), - - DONE("DONE"), - - FAILED("FAILED"), - - DISABLED("DISABLED"), - - PAUSED("PAUSED"), - - PARTIALLY_SYNCED("PARTIALLY_SYNCED"); - - private final String value; - - SyncStatusStatusEnum(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/filestorage/users/AsyncRawUsersClient.java b/src/main/java/com/merge/api/resources/filestorage/users/AsyncRawUsersClient.java new file mode 100644 index 000000000..6acd561c2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/users/AsyncRawUsersClient.java @@ -0,0 +1,233 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.users; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.PaginatedUserList; +import com.merge.api.resources.filestorage.types.User; +import com.merge.api.resources.filestorage.users.requests.UsersListRequest; +import com.merge.api.resources.filestorage.users.requests.UsersRetrieveRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawUsersClient { + protected final ClientOptions clientOptions; + + public AsyncRawUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> list() { + return list(UsersListRequest.builder().build()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> list(UsersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> list( + UsersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/users"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsMe().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_me", request.getIsMe().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, UsersRetrieveRequest.builder().build()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture> retrieve(String id, UsersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture> retrieve( + String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/users") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), User.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/users/AsyncUsersClient.java b/src/main/java/com/merge/api/resources/filestorage/users/AsyncUsersClient.java new file mode 100644 index 000000000..a674b835e --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/users/AsyncUsersClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.users; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.PaginatedUserList; +import com.merge.api.resources.filestorage.types.User; +import com.merge.api.resources.filestorage.users.requests.UsersListRequest; +import com.merge.api.resources.filestorage.users.requests.UsersRetrieveRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncUsersClient { + protected final ClientOptions clientOptions; + + private final AsyncRawUsersClient rawClient; + + public AsyncUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawUsersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawUsersClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture list(UsersListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture list(UsersListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture retrieve(String id, UsersRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture retrieve(String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/users/RawUsersClient.java b/src/main/java/com/merge/api/resources/filestorage/users/RawUsersClient.java new file mode 100644 index 000000000..e19a47bbf --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/users/RawUsersClient.java @@ -0,0 +1,200 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.users; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.PaginatedUserList; +import com.merge.api.resources.filestorage.types.User; +import com.merge.api.resources.filestorage.users.requests.UsersListRequest; +import com.merge.api.resources.filestorage.users.requests.UsersRetrieveRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawUsersClient { + protected final ClientOptions clientOptions; + + public RawUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse list() { + return list(UsersListRequest.builder().build()); + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse list(UsersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse list(UsersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/users"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsMe().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_me", request.getIsMe().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a User object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, UsersRetrieveRequest.builder().build()); + } + + /** + * Returns a User object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, UsersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a User object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/users") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), User.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/users/UsersClient.java b/src/main/java/com/merge/api/resources/filestorage/users/UsersClient.java index 416861fba..6be9c44bb 100644 --- a/src/main/java/com/merge/api/resources/filestorage/users/UsersClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/users/UsersClient.java @@ -3,167 +3,69 @@ */ package com.merge.api.resources.filestorage.users; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.types.PaginatedUserList; import com.merge.api.resources.filestorage.types.User; import com.merge.api.resources.filestorage.users.requests.UsersListRequest; import com.merge.api.resources.filestorage.users.requests.UsersRetrieveRequest; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class UsersClient { protected final ClientOptions clientOptions; + private final RawUsersClient rawClient; + public UsersClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawUsersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawUsersClient withRawResponse() { + return this.rawClient; } /** * Returns a list of User objects. */ public PaginatedUserList list() { - return list(UsersListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of User objects. */ public PaginatedUserList list(UsersListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of User objects. */ public PaginatedUserList list(UsersListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/users"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsMe().isPresent()) { - httpUrl.addQueryParameter("is_me", request.getIsMe().get()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a User object with the given id. */ public User retrieve(String id) { - return retrieve(id, UsersRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a User object with the given id. */ public User retrieve(String id, UsersRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a User object with the given id. */ public User retrieve(String id, UsersRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/users") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), User.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/filestorage/users/requests/UsersRetrieveRequest.java b/src/main/java/com/merge/api/resources/filestorage/users/requests/UsersRetrieveRequest.java index 7e2023f73..aa3691dca 100644 --- a/src/main/java/com/merge/api/resources/filestorage/users/requests/UsersRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/filestorage/users/requests/UsersRetrieveRequest.java @@ -22,10 +22,16 @@ public final class UsersRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private UsersRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private UsersRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(UsersRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(UsersRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public UsersRetrieveRequest build() { - return new UsersRetrieveRequest(includeRemoteData, additionalProperties); + return new UsersRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/AsyncRawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/AsyncRawWebhookReceiversClient.java new file mode 100644 index 000000000..7296c11f9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/AsyncRawWebhookReceiversClient.java @@ -0,0 +1,160 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.WebhookReceiver; +import com.merge.api.resources.filestorage.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public AsyncRawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create( + WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/AsyncWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/AsyncWebhookReceiversClient.java new file mode 100644 index 000000000..4b8f8468f --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/AsyncWebhookReceiversClient.java @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.webhookreceivers; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.WebhookReceiver; +import com.merge.api.resources.filestorage.webhookreceivers.requests.WebhookReceiverRequest; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncWebhookReceiversClient { + protected final ClientOptions clientOptions; + + private final AsyncRawWebhookReceiversClient rawClient; + + public AsyncWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawWebhookReceiversClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/RawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/RawWebhookReceiversClient.java new file mode 100644 index 000000000..9aeeee94a --- /dev/null +++ b/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/RawWebhookReceiversClient.java @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.filestorage.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.filestorage.types.WebhookReceiver; +import com.merge.api.resources.filestorage.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public RawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("filestorage/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/WebhookReceiversClient.java b/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/WebhookReceiversClient.java index 565a856ee..6570a397d 100644 --- a/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/WebhookReceiversClient.java +++ b/src/main/java/com/merge/api/resources/filestorage/webhookreceivers/WebhookReceiversClient.java @@ -3,120 +3,54 @@ */ package com.merge.api.resources.filestorage.webhookreceivers; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.filestorage.types.WebhookReceiver; import com.merge.api.resources.filestorage.webhookreceivers.requests.WebhookReceiverRequest; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class WebhookReceiversClient { protected final ClientOptions clientOptions; + private final RawWebhookReceiversClient rawClient; + public WebhookReceiversClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawWebhookReceiversClient withRawResponse() { + return this.rawClient; } /** * Returns a list of WebhookReceiver objects. */ public List list() { - return list(null); + return this.rawClient.list().body(); } /** * Returns a list of WebhookReceiver objects. */ public List list(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/webhook-receivers") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(requestOptions).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("filestorage/v1/webhook-receivers") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/AsyncHrisClient.java b/src/main/java/com/merge/api/resources/hris/AsyncHrisClient.java new file mode 100644 index 000000000..c2260a87a --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/AsyncHrisClient.java @@ -0,0 +1,280 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.Suppliers; +import com.merge.api.resources.hris.accountdetails.AsyncAccountDetailsClient; +import com.merge.api.resources.hris.accounttoken.AsyncAccountTokenClient; +import com.merge.api.resources.hris.asyncpassthrough.AsyncAsyncPassthroughClient; +import com.merge.api.resources.hris.audittrail.AsyncAuditTrailClient; +import com.merge.api.resources.hris.availableactions.AsyncAvailableActionsClient; +import com.merge.api.resources.hris.bankinfo.AsyncBankInfoClient; +import com.merge.api.resources.hris.benefits.AsyncBenefitsClient; +import com.merge.api.resources.hris.companies.AsyncCompaniesClient; +import com.merge.api.resources.hris.deleteaccount.AsyncDeleteAccountClient; +import com.merge.api.resources.hris.dependents.AsyncDependentsClient; +import com.merge.api.resources.hris.employeepayrollruns.AsyncEmployeePayrollRunsClient; +import com.merge.api.resources.hris.employees.AsyncEmployeesClient; +import com.merge.api.resources.hris.employerbenefits.AsyncEmployerBenefitsClient; +import com.merge.api.resources.hris.employments.AsyncEmploymentsClient; +import com.merge.api.resources.hris.fieldmapping.AsyncFieldMappingClient; +import com.merge.api.resources.hris.forceresync.AsyncForceResyncClient; +import com.merge.api.resources.hris.generatekey.AsyncGenerateKeyClient; +import com.merge.api.resources.hris.groups.AsyncGroupsClient; +import com.merge.api.resources.hris.issues.AsyncIssuesClient; +import com.merge.api.resources.hris.linkedaccounts.AsyncLinkedAccountsClient; +import com.merge.api.resources.hris.linktoken.AsyncLinkTokenClient; +import com.merge.api.resources.hris.locations.AsyncLocationsClient; +import com.merge.api.resources.hris.passthrough.AsyncPassthroughClient; +import com.merge.api.resources.hris.paygroups.AsyncPayGroupsClient; +import com.merge.api.resources.hris.payrollruns.AsyncPayrollRunsClient; +import com.merge.api.resources.hris.regeneratekey.AsyncRegenerateKeyClient; +import com.merge.api.resources.hris.scopes.AsyncScopesClient; +import com.merge.api.resources.hris.syncstatus.AsyncSyncStatusClient; +import com.merge.api.resources.hris.teams.AsyncTeamsClient; +import com.merge.api.resources.hris.timeoff.AsyncTimeOffClient; +import com.merge.api.resources.hris.timeoffbalances.AsyncTimeOffBalancesClient; +import com.merge.api.resources.hris.timesheetentries.AsyncTimesheetEntriesClient; +import com.merge.api.resources.hris.webhookreceivers.AsyncWebhookReceiversClient; +import java.util.function.Supplier; + +public class AsyncHrisClient { + protected final ClientOptions clientOptions; + + protected final Supplier accountDetailsClient; + + protected final Supplier accountTokenClient; + + protected final Supplier asyncPassthroughClient; + + protected final Supplier auditTrailClient; + + protected final Supplier availableActionsClient; + + protected final Supplier bankInfoClient; + + protected final Supplier benefitsClient; + + protected final Supplier companiesClient; + + protected final Supplier scopesClient; + + protected final Supplier deleteAccountClient; + + protected final Supplier dependentsClient; + + protected final Supplier employeePayrollRunsClient; + + protected final Supplier employeesClient; + + protected final Supplier employerBenefitsClient; + + protected final Supplier employmentsClient; + + protected final Supplier fieldMappingClient; + + protected final Supplier generateKeyClient; + + protected final Supplier groupsClient; + + protected final Supplier issuesClient; + + protected final Supplier linkTokenClient; + + protected final Supplier linkedAccountsClient; + + protected final Supplier locationsClient; + + protected final Supplier passthroughClient; + + protected final Supplier payGroupsClient; + + protected final Supplier payrollRunsClient; + + protected final Supplier regenerateKeyClient; + + protected final Supplier syncStatusClient; + + protected final Supplier forceResyncClient; + + protected final Supplier teamsClient; + + protected final Supplier timeOffClient; + + protected final Supplier timeOffBalancesClient; + + protected final Supplier timesheetEntriesClient; + + protected final Supplier webhookReceiversClient; + + public AsyncHrisClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.accountDetailsClient = Suppliers.memoize(() -> new AsyncAccountDetailsClient(clientOptions)); + this.accountTokenClient = Suppliers.memoize(() -> new AsyncAccountTokenClient(clientOptions)); + this.asyncPassthroughClient = Suppliers.memoize(() -> new AsyncAsyncPassthroughClient(clientOptions)); + this.auditTrailClient = Suppliers.memoize(() -> new AsyncAuditTrailClient(clientOptions)); + this.availableActionsClient = Suppliers.memoize(() -> new AsyncAvailableActionsClient(clientOptions)); + this.bankInfoClient = Suppliers.memoize(() -> new AsyncBankInfoClient(clientOptions)); + this.benefitsClient = Suppliers.memoize(() -> new AsyncBenefitsClient(clientOptions)); + this.companiesClient = Suppliers.memoize(() -> new AsyncCompaniesClient(clientOptions)); + this.scopesClient = Suppliers.memoize(() -> new AsyncScopesClient(clientOptions)); + this.deleteAccountClient = Suppliers.memoize(() -> new AsyncDeleteAccountClient(clientOptions)); + this.dependentsClient = Suppliers.memoize(() -> new AsyncDependentsClient(clientOptions)); + this.employeePayrollRunsClient = Suppliers.memoize(() -> new AsyncEmployeePayrollRunsClient(clientOptions)); + this.employeesClient = Suppliers.memoize(() -> new AsyncEmployeesClient(clientOptions)); + this.employerBenefitsClient = Suppliers.memoize(() -> new AsyncEmployerBenefitsClient(clientOptions)); + this.employmentsClient = Suppliers.memoize(() -> new AsyncEmploymentsClient(clientOptions)); + this.fieldMappingClient = Suppliers.memoize(() -> new AsyncFieldMappingClient(clientOptions)); + this.generateKeyClient = Suppliers.memoize(() -> new AsyncGenerateKeyClient(clientOptions)); + this.groupsClient = Suppliers.memoize(() -> new AsyncGroupsClient(clientOptions)); + this.issuesClient = Suppliers.memoize(() -> new AsyncIssuesClient(clientOptions)); + this.linkTokenClient = Suppliers.memoize(() -> new AsyncLinkTokenClient(clientOptions)); + this.linkedAccountsClient = Suppliers.memoize(() -> new AsyncLinkedAccountsClient(clientOptions)); + this.locationsClient = Suppliers.memoize(() -> new AsyncLocationsClient(clientOptions)); + this.passthroughClient = Suppliers.memoize(() -> new AsyncPassthroughClient(clientOptions)); + this.payGroupsClient = Suppliers.memoize(() -> new AsyncPayGroupsClient(clientOptions)); + this.payrollRunsClient = Suppliers.memoize(() -> new AsyncPayrollRunsClient(clientOptions)); + this.regenerateKeyClient = Suppliers.memoize(() -> new AsyncRegenerateKeyClient(clientOptions)); + this.syncStatusClient = Suppliers.memoize(() -> new AsyncSyncStatusClient(clientOptions)); + this.forceResyncClient = Suppliers.memoize(() -> new AsyncForceResyncClient(clientOptions)); + this.teamsClient = Suppliers.memoize(() -> new AsyncTeamsClient(clientOptions)); + this.timeOffClient = Suppliers.memoize(() -> new AsyncTimeOffClient(clientOptions)); + this.timeOffBalancesClient = Suppliers.memoize(() -> new AsyncTimeOffBalancesClient(clientOptions)); + this.timesheetEntriesClient = Suppliers.memoize(() -> new AsyncTimesheetEntriesClient(clientOptions)); + this.webhookReceiversClient = Suppliers.memoize(() -> new AsyncWebhookReceiversClient(clientOptions)); + } + + public AsyncAccountDetailsClient accountDetails() { + return this.accountDetailsClient.get(); + } + + public AsyncAccountTokenClient accountToken() { + return this.accountTokenClient.get(); + } + + public AsyncAsyncPassthroughClient asyncPassthrough() { + return this.asyncPassthroughClient.get(); + } + + public AsyncAuditTrailClient auditTrail() { + return this.auditTrailClient.get(); + } + + public AsyncAvailableActionsClient availableActions() { + return this.availableActionsClient.get(); + } + + public AsyncBankInfoClient bankInfo() { + return this.bankInfoClient.get(); + } + + public AsyncBenefitsClient benefits() { + return this.benefitsClient.get(); + } + + public AsyncCompaniesClient companies() { + return this.companiesClient.get(); + } + + public AsyncScopesClient scopes() { + return this.scopesClient.get(); + } + + public AsyncDeleteAccountClient deleteAccount() { + return this.deleteAccountClient.get(); + } + + public AsyncDependentsClient dependents() { + return this.dependentsClient.get(); + } + + public AsyncEmployeePayrollRunsClient employeePayrollRuns() { + return this.employeePayrollRunsClient.get(); + } + + public AsyncEmployeesClient employees() { + return this.employeesClient.get(); + } + + public AsyncEmployerBenefitsClient employerBenefits() { + return this.employerBenefitsClient.get(); + } + + public AsyncEmploymentsClient employments() { + return this.employmentsClient.get(); + } + + public AsyncFieldMappingClient fieldMapping() { + return this.fieldMappingClient.get(); + } + + public AsyncGenerateKeyClient generateKey() { + return this.generateKeyClient.get(); + } + + public AsyncGroupsClient groups() { + return this.groupsClient.get(); + } + + public AsyncIssuesClient issues() { + return this.issuesClient.get(); + } + + public AsyncLinkTokenClient linkToken() { + return this.linkTokenClient.get(); + } + + public AsyncLinkedAccountsClient linkedAccounts() { + return this.linkedAccountsClient.get(); + } + + public AsyncLocationsClient locations() { + return this.locationsClient.get(); + } + + public AsyncPassthroughClient passthrough() { + return this.passthroughClient.get(); + } + + public AsyncPayGroupsClient payGroups() { + return this.payGroupsClient.get(); + } + + public AsyncPayrollRunsClient payrollRuns() { + return this.payrollRunsClient.get(); + } + + public AsyncRegenerateKeyClient regenerateKey() { + return this.regenerateKeyClient.get(); + } + + public AsyncSyncStatusClient syncStatus() { + return this.syncStatusClient.get(); + } + + public AsyncForceResyncClient forceResync() { + return this.forceResyncClient.get(); + } + + public AsyncTeamsClient teams() { + return this.teamsClient.get(); + } + + public AsyncTimeOffClient timeOff() { + return this.timeOffClient.get(); + } + + public AsyncTimeOffBalancesClient timeOffBalances() { + return this.timeOffBalancesClient.get(); + } + + public AsyncTimesheetEntriesClient timesheetEntries() { + return this.timesheetEntriesClient.get(); + } + + public AsyncWebhookReceiversClient webhookReceivers() { + return this.webhookReceiversClient.get(); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/accountdetails/AccountDetailsClient.java b/src/main/java/com/merge/api/resources/hris/accountdetails/AccountDetailsClient.java index 1c7970ea4..cda99db6a 100644 --- a/src/main/java/com/merge/api/resources/hris/accountdetails/AccountDetailsClient.java +++ b/src/main/java/com/merge/api/resources/hris/accountdetails/AccountDetailsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.hris.accountdetails; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.types.AccountDetails; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountDetailsClient { protected final ClientOptions clientOptions; + private final RawAccountDetailsClient rawClient; + public AccountDetailsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountDetailsClient withRawResponse() { + return this.rawClient; } /** * Get details for a linked account. */ public AccountDetails retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Get details for a linked account. */ public AccountDetails retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/account-details") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/accountdetails/AsyncAccountDetailsClient.java b/src/main/java/com/merge/api/resources/hris/accountdetails/AsyncAccountDetailsClient.java new file mode 100644 index 000000000..03832c450 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/accountdetails/AsyncAccountDetailsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.accountdetails; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.AccountDetails; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountDetailsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountDetailsClient rawClient; + + public AsyncAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountDetailsClient withRawResponse() { + return this.rawClient; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/accountdetails/AsyncRawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/hris/accountdetails/AsyncRawAccountDetailsClient.java new file mode 100644 index 000000000..1e3724819 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/accountdetails/AsyncRawAccountDetailsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.AccountDetails; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/accountdetails/RawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/hris/accountdetails/RawAccountDetailsClient.java new file mode 100644 index 000000000..27e51dd55 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/accountdetails/RawAccountDetailsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.AccountDetails; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public RawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/accounttoken/AccountTokenClient.java b/src/main/java/com/merge/api/resources/hris/accounttoken/AccountTokenClient.java index f677e3b19..70d4b7b38 100644 --- a/src/main/java/com/merge/api/resources/hris/accounttoken/AccountTokenClient.java +++ b/src/main/java/com/merge/api/resources/hris/accounttoken/AccountTokenClient.java @@ -3,66 +3,38 @@ */ package com.merge.api.resources.hris.accounttoken; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.types.AccountToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountTokenClient { protected final ClientOptions clientOptions; + private final RawAccountTokenClient rawClient; + public AccountTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountTokenClient withRawResponse() { + return this.rawClient; } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken) { - return retrieve(publicToken, null); + return this.rawClient.retrieve(publicToken).body(); } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/account-token") - .addPathSegment(publicToken) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(publicToken, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/accounttoken/AsyncAccountTokenClient.java b/src/main/java/com/merge/api/resources/hris/accounttoken/AsyncAccountTokenClient.java new file mode 100644 index 000000000..598ef643d --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/accounttoken/AsyncAccountTokenClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.accounttoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.AccountToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountTokenClient rawClient; + + public AsyncAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken) { + return this.rawClient.retrieve(publicToken).thenApply(response -> response.body()); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken, RequestOptions requestOptions) { + return this.rawClient.retrieve(publicToken, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/accounttoken/AsyncRawAccountTokenClient.java b/src/main/java/com/merge/api/resources/hris/accounttoken/AsyncRawAccountTokenClient.java new file mode 100644 index 000000000..1d2d04db4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/accounttoken/AsyncRawAccountTokenClient.java @@ -0,0 +1,90 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.AccountToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve( + String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/accounttoken/RawAccountTokenClient.java b/src/main/java/com/merge/api/resources/hris/accounttoken/RawAccountTokenClient.java new file mode 100644 index 000000000..a51de3d9b --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/accounttoken/RawAccountTokenClient.java @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.AccountToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountTokenClient { + protected final ClientOptions clientOptions; + + public RawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/asyncpassthrough/AsyncAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/hris/asyncpassthrough/AsyncAsyncPassthroughClient.java new file mode 100644 index 000000000..923e5a2ad --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/asyncpassthrough/AsyncAsyncPassthroughClient.java @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.asyncpassthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.hris.types.AsyncPassthroughReciept; +import com.merge.api.resources.hris.types.DataPassthroughRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAsyncPassthroughClient rawClient; + + public AsyncAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAsyncPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create( + DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve(String asyncPassthroughReceiptId) { + return this.rawClient.retrieve(asyncPassthroughReceiptId).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/asyncpassthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/hris/asyncpassthrough/AsyncPassthroughClient.java index c70b057da..e1f46d06c 100644 --- a/src/main/java/com/merge/api/resources/hris/asyncpassthrough/AsyncPassthroughClient.java +++ b/src/main/java/com/merge/api/resources/hris/asyncpassthrough/AsyncPassthroughClient.java @@ -3,119 +3,56 @@ */ package com.merge.api.resources.hris.asyncpassthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; import com.merge.api.resources.hris.types.AsyncPassthroughReciept; import com.merge.api.resources.hris.types.DataPassthroughRequest; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AsyncPassthroughClient { protected final ClientOptions clientOptions; + private final RawAsyncPassthroughClient rawClient; + public AsyncPassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAsyncPassthroughClient withRawResponse() { + return this.rawClient; } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/async-passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId) { - return retrieve(asyncPassthroughReceiptId, null); + return this.rawClient.retrieve(asyncPassthroughReceiptId).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/async-passthrough") - .addPathSegment(asyncPassthroughReceiptId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), AsyncPassthroughRetrieveResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/asyncpassthrough/AsyncRawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/hris/asyncpassthrough/AsyncRawAsyncPassthroughClient.java new file mode 100644 index 000000000..c369b1e59 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/asyncpassthrough/AsyncRawAsyncPassthroughClient.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.hris.types.AsyncPassthroughReciept; +import com.merge.api.resources.hris.types.DataPassthroughRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughReciept.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/asyncpassthrough/RawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/hris/asyncpassthrough/RawAsyncPassthroughClient.java new file mode 100644 index 000000000..fed169d69 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/asyncpassthrough/RawAsyncPassthroughClient.java @@ -0,0 +1,131 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.hris.types.AsyncPassthroughReciept; +import com.merge.api.resources.hris.types.DataPassthroughRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public RawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve(String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java b/src/main/java/com/merge/api/resources/hris/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java index 492f45945..6bb9ecb4d 100644 --- a/src/main/java/com/merge/api/resources/hris/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java +++ b/src/main/java/com/merge/api/resources/hris/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java @@ -30,6 +30,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((RemoteResponse) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list(AuditTrailListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list( + AuditTrailListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/audittrail/AsyncRawAuditTrailClient.java b/src/main/java/com/merge/api/resources/hris/audittrail/AsyncRawAuditTrailClient.java new file mode 100644 index 000000000..fc85617fb --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/audittrail/AsyncRawAuditTrailClient.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.hris.types.PaginatedAuditLogEventList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAuditTrailClient { + protected final ClientOptions clientOptions; + + public AsyncRawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAuditLogEventList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/audittrail/AuditTrailClient.java b/src/main/java/com/merge/api/resources/hris/audittrail/AuditTrailClient.java index a5537eea6..6b4bfffac 100644 --- a/src/main/java/com/merge/api/resources/hris/audittrail/AuditTrailClient.java +++ b/src/main/java/com/merge/api/resources/hris/audittrail/AuditTrailClient.java @@ -3,90 +3,46 @@ */ package com.merge.api.resources.hris.audittrail; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.audittrail.requests.AuditTrailListRequest; import com.merge.api.resources.hris.types.PaginatedAuditLogEventList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AuditTrailClient { protected final ClientOptions clientOptions; + private final RawAuditTrailClient rawClient; + public AuditTrailClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAuditTrailClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAuditTrailClient withRawResponse() { + return this.rawClient; } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list() { - return list(AuditTrailListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/audit-trail"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEventType().isPresent()) { - httpUrl.addQueryParameter("event_type", request.getEventType().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getUserEmail().isPresent()) { - httpUrl.addQueryParameter("user_email", request.getUserEmail().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/audittrail/RawAuditTrailClient.java b/src/main/java/com/merge/api/resources/hris/audittrail/RawAuditTrailClient.java new file mode 100644 index 000000000..0e2bb88cd --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/audittrail/RawAuditTrailClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.hris.types.PaginatedAuditLogEventList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAuditTrailClient { + protected final ClientOptions clientOptions; + + public RawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/audittrail/requests/AuditTrailListRequest.java b/src/main/java/com/merge/api/resources/hris/audittrail/requests/AuditTrailListRequest.java index 8841a60c8..3c1d115b1 100644 --- a/src/main/java/com/merge/api/resources/hris/audittrail/requests/AuditTrailListRequest.java +++ b/src/main/java/com/merge/api/resources/hris/audittrail/requests/AuditTrailListRequest.java @@ -68,7 +68,7 @@ public Optional getEndDate() { } /** - * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED + * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED */ @JsonProperty("event_type") public Optional getEventType() { diff --git a/src/main/java/com/merge/api/resources/hris/availableactions/AsyncAvailableActionsClient.java b/src/main/java/com/merge/api/resources/hris/availableactions/AsyncAvailableActionsClient.java new file mode 100644 index 000000000..2bdfa7693 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/availableactions/AsyncAvailableActionsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.availableactions; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.AvailableActions; +import java.util.concurrent.CompletableFuture; + +public class AsyncAvailableActionsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAvailableActionsClient rawClient; + + public AsyncAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAvailableActionsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/availableactions/AsyncRawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/hris/availableactions/AsyncRawAvailableActionsClient.java new file mode 100644 index 000000000..f235fd463 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/availableactions/AsyncRawAvailableActionsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.AvailableActions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/availableactions/AvailableActionsClient.java b/src/main/java/com/merge/api/resources/hris/availableactions/AvailableActionsClient.java index a7c3252db..da0ce5b0d 100644 --- a/src/main/java/com/merge/api/resources/hris/availableactions/AvailableActionsClient.java +++ b/src/main/java/com/merge/api/resources/hris/availableactions/AvailableActionsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.hris.availableactions; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.types.AvailableActions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AvailableActionsClient { protected final ClientOptions clientOptions; + private final RawAvailableActionsClient rawClient; + public AvailableActionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAvailableActionsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/available-actions") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/availableactions/RawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/hris/availableactions/RawAvailableActionsClient.java new file mode 100644 index 000000000..7185bc3d4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/availableactions/RawAvailableActionsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.AvailableActions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public RawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/bankinfo/AsyncBankInfoClient.java b/src/main/java/com/merge/api/resources/hris/bankinfo/AsyncBankInfoClient.java new file mode 100644 index 000000000..3bd28225d --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/bankinfo/AsyncBankInfoClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.bankinfo; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.bankinfo.requests.BankInfoListRequest; +import com.merge.api.resources.hris.bankinfo.requests.BankInfoRetrieveRequest; +import com.merge.api.resources.hris.types.BankInfo; +import com.merge.api.resources.hris.types.PaginatedBankInfoList; +import java.util.concurrent.CompletableFuture; + +public class AsyncBankInfoClient { + protected final ClientOptions clientOptions; + + private final AsyncRawBankInfoClient rawClient; + + public AsyncBankInfoClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawBankInfoClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawBankInfoClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of BankInfo objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of BankInfo objects. + */ + public CompletableFuture list(BankInfoListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of BankInfo objects. + */ + public CompletableFuture list(BankInfoListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a BankInfo object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a BankInfo object with the given id. + */ + public CompletableFuture retrieve(String id, BankInfoRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a BankInfo object with the given id. + */ + public CompletableFuture retrieve( + String id, BankInfoRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/bankinfo/AsyncRawBankInfoClient.java b/src/main/java/com/merge/api/resources/hris/bankinfo/AsyncRawBankInfoClient.java new file mode 100644 index 000000000..b43c8e5b2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/bankinfo/AsyncRawBankInfoClient.java @@ -0,0 +1,269 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.bankinfo; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.bankinfo.requests.BankInfoListRequest; +import com.merge.api.resources.hris.bankinfo.requests.BankInfoRetrieveRequest; +import com.merge.api.resources.hris.types.BankInfo; +import com.merge.api.resources.hris.types.PaginatedBankInfoList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawBankInfoClient { + protected final ClientOptions clientOptions; + + public AsyncRawBankInfoClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of BankInfo objects. + */ + public CompletableFuture> list() { + return list(BankInfoListRequest.builder().build()); + } + + /** + * Returns a list of BankInfo objects. + */ + public CompletableFuture> list(BankInfoListRequest request) { + return list(request, null); + } + + /** + * Returns a list of BankInfo objects. + */ + public CompletableFuture> list( + BankInfoListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/bank-info"); + if (request.getAccountType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_type", request.getAccountType().get().toString(), false); + } + if (request.getBankName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "bank_name", request.getBankName().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOrderBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order_by", request.getOrderBy().get().toString(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedBankInfoList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a BankInfo object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, BankInfoRetrieveRequest.builder().build()); + } + + /** + * Returns a BankInfo object with the given id. + */ + public CompletableFuture> retrieve(String id, BankInfoRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a BankInfo object with the given id. + */ + public CompletableFuture> retrieve( + String id, BankInfoRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/bank-info") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankInfo.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/bankinfo/BankInfoClient.java b/src/main/java/com/merge/api/resources/hris/bankinfo/BankInfoClient.java index edf4ce888..3467a5d8d 100644 --- a/src/main/java/com/merge/api/resources/hris/bankinfo/BankInfoClient.java +++ b/src/main/java/com/merge/api/resources/hris/bankinfo/BankInfoClient.java @@ -3,197 +3,69 @@ */ package com.merge.api.resources.hris.bankinfo; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.bankinfo.requests.BankInfoListRequest; import com.merge.api.resources.hris.bankinfo.requests.BankInfoRetrieveRequest; import com.merge.api.resources.hris.types.BankInfo; import com.merge.api.resources.hris.types.PaginatedBankInfoList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class BankInfoClient { protected final ClientOptions clientOptions; + private final RawBankInfoClient rawClient; + public BankInfoClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawBankInfoClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawBankInfoClient withRawResponse() { + return this.rawClient; } /** * Returns a list of BankInfo objects. */ public PaginatedBankInfoList list() { - return list(BankInfoListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of BankInfo objects. */ public PaginatedBankInfoList list(BankInfoListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of BankInfo objects. */ public PaginatedBankInfoList list(BankInfoListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/bank-info"); - if (request.getAccountType().isPresent()) { - httpUrl.addQueryParameter( - "account_type", request.getAccountType().get().toString()); - } - if (request.getBankName().isPresent()) { - httpUrl.addQueryParameter("bank_name", request.getBankName().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmployeeId().isPresent()) { - httpUrl.addQueryParameter("employee_id", request.getEmployeeId().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getOrderBy().isPresent()) { - httpUrl.addQueryParameter("order_by", request.getOrderBy().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedBankInfoList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a BankInfo object with the given id. */ public BankInfo retrieve(String id) { - return retrieve(id, BankInfoRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a BankInfo object with the given id. */ public BankInfo retrieve(String id, BankInfoRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a BankInfo object with the given id. */ public BankInfo retrieve(String id, BankInfoRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/bank-info") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankInfo.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/bankinfo/RawBankInfoClient.java b/src/main/java/com/merge/api/resources/hris/bankinfo/RawBankInfoClient.java new file mode 100644 index 000000000..88118349d --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/bankinfo/RawBankInfoClient.java @@ -0,0 +1,239 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.bankinfo; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.bankinfo.requests.BankInfoListRequest; +import com.merge.api.resources.hris.bankinfo.requests.BankInfoRetrieveRequest; +import com.merge.api.resources.hris.types.BankInfo; +import com.merge.api.resources.hris.types.PaginatedBankInfoList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawBankInfoClient { + protected final ClientOptions clientOptions; + + public RawBankInfoClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of BankInfo objects. + */ + public MergeApiHttpResponse list() { + return list(BankInfoListRequest.builder().build()); + } + + /** + * Returns a list of BankInfo objects. + */ + public MergeApiHttpResponse list(BankInfoListRequest request) { + return list(request, null); + } + + /** + * Returns a list of BankInfo objects. + */ + public MergeApiHttpResponse list( + BankInfoListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/bank-info"); + if (request.getAccountType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_type", request.getAccountType().get().toString(), false); + } + if (request.getBankName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "bank_name", request.getBankName().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOrderBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order_by", request.getOrderBy().get().toString(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedBankInfoList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a BankInfo object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, BankInfoRetrieveRequest.builder().build()); + } + + /** + * Returns a BankInfo object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, BankInfoRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a BankInfo object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, BankInfoRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/bank-info") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BankInfo.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/bankinfo/requests/BankInfoListRequest.java b/src/main/java/com/merge/api/resources/hris/bankinfo/requests/BankInfoListRequest.java index 4c376d118..28a0582a6 100644 --- a/src/main/java/com/merge/api/resources/hris/bankinfo/requests/BankInfoListRequest.java +++ b/src/main/java/com/merge/api/resources/hris/bankinfo/requests/BankInfoListRequest.java @@ -15,7 +15,9 @@ import com.merge.api.resources.hris.bankinfo.types.BankInfoListRequestAccountType; import com.merge.api.resources.hris.bankinfo.types.BankInfoListRequestOrderBy; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,6 +25,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BankInfoListRequest.Builder.class) public final class BankInfoListRequest { + private final Optional> expand; + private final Optional accountType; private final Optional bankName; @@ -35,8 +39,6 @@ public final class BankInfoListRequest { private final Optional employeeId; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -60,13 +62,13 @@ public final class BankInfoListRequest { private final Map additionalProperties; private BankInfoListRequest( + Optional> expand, Optional accountType, Optional bankName, Optional createdAfter, Optional createdBefore, Optional cursor, Optional employeeId, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -78,13 +80,13 @@ private BankInfoListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.accountType = accountType; this.bankName = bankName; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.employeeId = employeeId; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -98,6 +100,14 @@ private BankInfoListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return BankInfo's with this account type. Options: ('SAVINGS', 'CHECKING') *
      @@ -150,14 +160,6 @@ public Optional getEmployeeId() { return employeeId; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -250,13 +252,13 @@ public Map getAdditionalProperties() { } private boolean equalTo(BankInfoListRequest other) { - return accountType.equals(other.accountType) + return expand.equals(other.expand) + && accountType.equals(other.accountType) && bankName.equals(other.bankName) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && employeeId.equals(other.employeeId) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -272,13 +274,13 @@ private boolean equalTo(BankInfoListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.accountType, this.bankName, this.createdAfter, this.createdBefore, this.cursor, this.employeeId, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -302,6 +304,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional accountType = Optional.empty(); private Optional bankName = Optional.empty(); @@ -314,8 +318,6 @@ public static final class Builder { private Optional employeeId = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -342,13 +344,13 @@ public static final class Builder { private Builder() {} public Builder from(BankInfoListRequest other) { + expand(other.getExpand()); accountType(other.getAccountType()); bankName(other.getBankName()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); employeeId(other.getEmployeeId()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -362,6 +364,22 @@ public Builder from(BankInfoListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "account_type", nulls = Nulls.SKIP) public Builder accountType(Optional accountType) { this.accountType = accountType; @@ -428,17 +446,6 @@ public Builder employeeId(String employeeId) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -551,13 +558,13 @@ public Builder showEnumOrigins(String showEnumOrigins) { public BankInfoListRequest build() { return new BankInfoListRequest( + expand, accountType, bankName, createdAfter, createdBefore, cursor, employeeId, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/hris/bankinfo/requests/BankInfoRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/bankinfo/requests/BankInfoRetrieveRequest.java index b3b148909..bfb5ab77d 100644 --- a/src/main/java/com/merge/api/resources/hris/bankinfo/requests/BankInfoRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/bankinfo/requests/BankInfoRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,10 +22,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BankInfoRetrieveRequest.Builder.class) public final class BankInfoRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -31,13 +35,15 @@ public final class BankInfoRetrieveRequest { private final Map additionalProperties; private BankInfoRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -47,7 +53,7 @@ private BankInfoRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -59,6 +65,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -89,13 +103,15 @@ public Map getAdditionalProperties() { private boolean equalTo(BankInfoRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -109,10 +125,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -125,22 +143,28 @@ private Builder() {} public Builder from(BankInfoRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -152,6 +176,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -176,7 +211,7 @@ public Builder showEnumOrigins(String showEnumOrigins) { public BankInfoRetrieveRequest build() { return new BankInfoRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/benefits/AsyncBenefitsClient.java b/src/main/java/com/merge/api/resources/hris/benefits/AsyncBenefitsClient.java new file mode 100644 index 000000000..f13b1b28f --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/benefits/AsyncBenefitsClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.benefits; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.benefits.requests.BenefitsListRequest; +import com.merge.api.resources.hris.benefits.requests.BenefitsRetrieveRequest; +import com.merge.api.resources.hris.types.Benefit; +import com.merge.api.resources.hris.types.PaginatedBenefitList; +import java.util.concurrent.CompletableFuture; + +public class AsyncBenefitsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawBenefitsClient rawClient; + + public AsyncBenefitsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawBenefitsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawBenefitsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Benefit objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Benefit objects. + */ + public CompletableFuture list(BenefitsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Benefit objects. + */ + public CompletableFuture list(BenefitsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Benefit object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Benefit object with the given id. + */ + public CompletableFuture retrieve(String id, BenefitsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Benefit object with the given id. + */ + public CompletableFuture retrieve( + String id, BenefitsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/benefits/AsyncRawBenefitsClient.java b/src/main/java/com/merge/api/resources/hris/benefits/AsyncRawBenefitsClient.java new file mode 100644 index 000000000..6b79c73e9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/benefits/AsyncRawBenefitsClient.java @@ -0,0 +1,241 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.benefits; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.benefits.requests.BenefitsListRequest; +import com.merge.api.resources.hris.benefits.requests.BenefitsRetrieveRequest; +import com.merge.api.resources.hris.types.Benefit; +import com.merge.api.resources.hris.types.PaginatedBenefitList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawBenefitsClient { + protected final ClientOptions clientOptions; + + public AsyncRawBenefitsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Benefit objects. + */ + public CompletableFuture> list() { + return list(BenefitsListRequest.builder().build()); + } + + /** + * Returns a list of Benefit objects. + */ + public CompletableFuture> list(BenefitsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Benefit objects. + */ + public CompletableFuture> list( + BenefitsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/benefits"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedBenefitList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Benefit object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, BenefitsRetrieveRequest.builder().build()); + } + + /** + * Returns a Benefit object with the given id. + */ + public CompletableFuture> retrieve(String id, BenefitsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Benefit object with the given id. + */ + public CompletableFuture> retrieve( + String id, BenefitsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/benefits") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Benefit.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/benefits/BenefitsClient.java b/src/main/java/com/merge/api/resources/hris/benefits/BenefitsClient.java index 550f35e81..3014b5734 100644 --- a/src/main/java/com/merge/api/resources/hris/benefits/BenefitsClient.java +++ b/src/main/java/com/merge/api/resources/hris/benefits/BenefitsClient.java @@ -3,173 +3,69 @@ */ package com.merge.api.resources.hris.benefits; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.benefits.requests.BenefitsListRequest; import com.merge.api.resources.hris.benefits.requests.BenefitsRetrieveRequest; import com.merge.api.resources.hris.types.Benefit; import com.merge.api.resources.hris.types.PaginatedBenefitList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class BenefitsClient { protected final ClientOptions clientOptions; + private final RawBenefitsClient rawClient; + public BenefitsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawBenefitsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawBenefitsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Benefit objects. */ public PaginatedBenefitList list() { - return list(BenefitsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Benefit objects. */ public PaginatedBenefitList list(BenefitsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Benefit objects. */ public PaginatedBenefitList list(BenefitsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/benefits"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmployeeId().isPresent()) { - httpUrl.addQueryParameter("employee_id", request.getEmployeeId().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedBenefitList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Benefit object with the given id. */ public Benefit retrieve(String id) { - return retrieve(id, BenefitsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Benefit object with the given id. */ public Benefit retrieve(String id, BenefitsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Benefit object with the given id. */ public Benefit retrieve(String id, BenefitsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/benefits") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Benefit.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/benefits/RawBenefitsClient.java b/src/main/java/com/merge/api/resources/hris/benefits/RawBenefitsClient.java new file mode 100644 index 000000000..53efead47 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/benefits/RawBenefitsClient.java @@ -0,0 +1,210 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.benefits; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.benefits.requests.BenefitsListRequest; +import com.merge.api.resources.hris.benefits.requests.BenefitsRetrieveRequest; +import com.merge.api.resources.hris.types.Benefit; +import com.merge.api.resources.hris.types.PaginatedBenefitList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawBenefitsClient { + protected final ClientOptions clientOptions; + + public RawBenefitsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Benefit objects. + */ + public MergeApiHttpResponse list() { + return list(BenefitsListRequest.builder().build()); + } + + /** + * Returns a list of Benefit objects. + */ + public MergeApiHttpResponse list(BenefitsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Benefit objects. + */ + public MergeApiHttpResponse list(BenefitsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/benefits"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedBenefitList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Benefit object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, BenefitsRetrieveRequest.builder().build()); + } + + /** + * Returns a Benefit object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, BenefitsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Benefit object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, BenefitsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/benefits") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Benefit.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/benefits/requests/BenefitsListRequest.java b/src/main/java/com/merge/api/resources/hris/benefits/requests/BenefitsListRequest.java index 9888695b9..c1b28fc5e 100644 --- a/src/main/java/com/merge/api/resources/hris/benefits/requests/BenefitsListRequest.java +++ b/src/main/java/com/merge/api/resources/hris/benefits/requests/BenefitsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BenefitsListRequest.Builder.class) public final class BenefitsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; @@ -29,8 +33,6 @@ public final class BenefitsListRequest { private final Optional employeeId; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -48,11 +50,11 @@ public final class BenefitsListRequest { private final Map additionalProperties; private BenefitsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, Optional employeeId, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -61,11 +63,11 @@ private BenefitsListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.employeeId = employeeId; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -76,6 +78,14 @@ private BenefitsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -108,14 +118,6 @@ public Optional getEmployeeId() { return employeeId; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -184,11 +186,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(BenefitsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && employeeId.equals(other.employeeId) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -201,11 +203,11 @@ private boolean equalTo(BenefitsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, this.employeeId, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -226,6 +228,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); @@ -234,8 +238,6 @@ public static final class Builder { private Optional employeeId = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -256,11 +258,11 @@ public static final class Builder { private Builder() {} public Builder from(BenefitsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); employeeId(other.getEmployeeId()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -271,6 +273,22 @@ public Builder from(BenefitsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -315,17 +333,6 @@ public Builder employeeId(String employeeId) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -405,11 +412,11 @@ public Builder remoteId(String remoteId) { public BenefitsListRequest build() { return new BenefitsListRequest( + expand, createdAfter, createdBefore, cursor, employeeId, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/hris/benefits/requests/BenefitsRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/benefits/requests/BenefitsRetrieveRequest.java index 4f1744baf..930de834b 100644 --- a/src/main/java/com/merge/api/resources/hris/benefits/requests/BenefitsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/benefits/requests/BenefitsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = BenefitsRetrieveRequest.Builder.class) public final class BenefitsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private BenefitsRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private BenefitsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(BenefitsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(BenefitsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public BenefitsRetrieveRequest build() { - return new BenefitsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new BenefitsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/companies/AsyncCompaniesClient.java b/src/main/java/com/merge/api/resources/hris/companies/AsyncCompaniesClient.java new file mode 100644 index 000000000..df95c25fe --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/companies/AsyncCompaniesClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.companies; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.companies.requests.CompaniesListRequest; +import com.merge.api.resources.hris.companies.requests.CompaniesRetrieveRequest; +import com.merge.api.resources.hris.types.Company; +import com.merge.api.resources.hris.types.PaginatedCompanyList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCompaniesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCompaniesClient rawClient; + + public AsyncCompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCompaniesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCompaniesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Company objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Company objects. + */ + public CompletableFuture list(CompaniesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Company objects. + */ + public CompletableFuture list(CompaniesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Company object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Company object with the given id. + */ + public CompletableFuture retrieve(String id, CompaniesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Company object with the given id. + */ + public CompletableFuture retrieve( + String id, CompaniesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/companies/AsyncRawCompaniesClient.java b/src/main/java/com/merge/api/resources/hris/companies/AsyncRawCompaniesClient.java new file mode 100644 index 000000000..93a4fffaa --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/companies/AsyncRawCompaniesClient.java @@ -0,0 +1,229 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.companies; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.companies.requests.CompaniesListRequest; +import com.merge.api.resources.hris.companies.requests.CompaniesRetrieveRequest; +import com.merge.api.resources.hris.types.Company; +import com.merge.api.resources.hris.types.PaginatedCompanyList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCompaniesClient { + protected final ClientOptions clientOptions; + + public AsyncRawCompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Company objects. + */ + public CompletableFuture> list() { + return list(CompaniesListRequest.builder().build()); + } + + /** + * Returns a list of Company objects. + */ + public CompletableFuture> list(CompaniesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Company objects. + */ + public CompletableFuture> list( + CompaniesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/companies"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCompanyList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Company object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, CompaniesRetrieveRequest.builder().build()); + } + + /** + * Returns a Company object with the given id. + */ + public CompletableFuture> retrieve(String id, CompaniesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Company object with the given id. + */ + public CompletableFuture> retrieve( + String id, CompaniesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/companies") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/companies/CompaniesClient.java b/src/main/java/com/merge/api/resources/hris/companies/CompaniesClient.java index 6c205aead..62752e5d4 100644 --- a/src/main/java/com/merge/api/resources/hris/companies/CompaniesClient.java +++ b/src/main/java/com/merge/api/resources/hris/companies/CompaniesClient.java @@ -3,164 +3,69 @@ */ package com.merge.api.resources.hris.companies; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.companies.requests.CompaniesListRequest; import com.merge.api.resources.hris.companies.requests.CompaniesRetrieveRequest; import com.merge.api.resources.hris.types.Company; import com.merge.api.resources.hris.types.PaginatedCompanyList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class CompaniesClient { protected final ClientOptions clientOptions; + private final RawCompaniesClient rawClient; + public CompaniesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCompaniesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCompaniesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Company objects. */ public PaginatedCompanyList list() { - return list(CompaniesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Company objects. */ public PaginatedCompanyList list(CompaniesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Company objects. */ public PaginatedCompanyList list(CompaniesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/companies"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCompanyList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Company object with the given id. */ public Company retrieve(String id) { - return retrieve(id, CompaniesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Company object with the given id. */ public Company retrieve(String id, CompaniesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Company object with the given id. */ public Company retrieve(String id, CompaniesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/companies") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/companies/RawCompaniesClient.java b/src/main/java/com/merge/api/resources/hris/companies/RawCompaniesClient.java new file mode 100644 index 000000000..572b95f55 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/companies/RawCompaniesClient.java @@ -0,0 +1,199 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.companies; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.companies.requests.CompaniesListRequest; +import com.merge.api.resources.hris.companies.requests.CompaniesRetrieveRequest; +import com.merge.api.resources.hris.types.Company; +import com.merge.api.resources.hris.types.PaginatedCompanyList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCompaniesClient { + protected final ClientOptions clientOptions; + + public RawCompaniesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Company objects. + */ + public MergeApiHttpResponse list() { + return list(CompaniesListRequest.builder().build()); + } + + /** + * Returns a list of Company objects. + */ + public MergeApiHttpResponse list(CompaniesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Company objects. + */ + public MergeApiHttpResponse list( + CompaniesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/companies"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCompanyList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Company object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, CompaniesRetrieveRequest.builder().build()); + } + + /** + * Returns a Company object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, CompaniesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Company object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, CompaniesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/companies") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Company.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/companies/requests/CompaniesRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/companies/requests/CompaniesRetrieveRequest.java index 039d346cb..4e0b00893 100644 --- a/src/main/java/com/merge/api/resources/hris/companies/requests/CompaniesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/companies/requests/CompaniesRetrieveRequest.java @@ -22,10 +22,16 @@ public final class CompaniesRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private CompaniesRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private CompaniesRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(CompaniesRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(CompaniesRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public CompaniesRetrieveRequest build() { - return new CompaniesRetrieveRequest(includeRemoteData, additionalProperties); + return new CompaniesRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/deleteaccount/AsyncDeleteAccountClient.java b/src/main/java/com/merge/api/resources/hris/deleteaccount/AsyncDeleteAccountClient.java new file mode 100644 index 000000000..5dca030cc --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/deleteaccount/AsyncDeleteAccountClient.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.deleteaccount; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import java.util.concurrent.CompletableFuture; + +public class AsyncDeleteAccountClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDeleteAccountClient rawClient; + + public AsyncDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDeleteAccountClient withRawResponse() { + return this.rawClient; + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete() { + return this.rawClient.delete().thenApply(response -> response.body()); + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete(RequestOptions requestOptions) { + return this.rawClient.delete(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/deleteaccount/AsyncRawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/hris/deleteaccount/AsyncRawDeleteAccountClient.java new file mode 100644 index 000000000..a7354801b --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/deleteaccount/AsyncRawDeleteAccountClient.java @@ -0,0 +1,84 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public AsyncRawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/deleteaccount/DeleteAccountClient.java b/src/main/java/com/merge/api/resources/hris/deleteaccount/DeleteAccountClient.java index 034c27ba0..004829f87 100644 --- a/src/main/java/com/merge/api/resources/hris/deleteaccount/DeleteAccountClient.java +++ b/src/main/java/com/merge/api/resources/hris/deleteaccount/DeleteAccountClient.java @@ -3,63 +3,37 @@ */ package com.merge.api.resources.hris.deleteaccount; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class DeleteAccountClient { protected final ClientOptions clientOptions; + private final RawDeleteAccountClient rawClient; + public DeleteAccountClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDeleteAccountClient withRawResponse() { + return this.rawClient; } /** * Delete a linked account. */ public void delete() { - delete(null); + this.rawClient.delete().body(); } /** * Delete a linked account. */ public void delete(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/delete-account") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + this.rawClient.delete(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/deleteaccount/RawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/hris/deleteaccount/RawDeleteAccountClient.java new file mode 100644 index 000000000..f3de2affd --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/deleteaccount/RawDeleteAccountClient.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public RawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/dependents/AsyncDependentsClient.java b/src/main/java/com/merge/api/resources/hris/dependents/AsyncDependentsClient.java new file mode 100644 index 000000000..f9f76d71a --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/dependents/AsyncDependentsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.dependents; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.dependents.requests.DependentsListRequest; +import com.merge.api.resources.hris.dependents.requests.DependentsRetrieveRequest; +import com.merge.api.resources.hris.types.Dependent; +import com.merge.api.resources.hris.types.PaginatedDependentList; +import java.util.concurrent.CompletableFuture; + +public class AsyncDependentsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDependentsClient rawClient; + + public AsyncDependentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDependentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDependentsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Dependent objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Dependent objects. + */ + public CompletableFuture list(DependentsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Dependent objects. + */ + public CompletableFuture list( + DependentsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Dependent object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Dependent object with the given id. + */ + public CompletableFuture retrieve(String id, DependentsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Dependent object with the given id. + */ + public CompletableFuture retrieve( + String id, DependentsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/dependents/AsyncRawDependentsClient.java b/src/main/java/com/merge/api/resources/hris/dependents/AsyncRawDependentsClient.java new file mode 100644 index 000000000..0570eec8b --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/dependents/AsyncRawDependentsClient.java @@ -0,0 +1,244 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.dependents; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.dependents.requests.DependentsListRequest; +import com.merge.api.resources.hris.dependents.requests.DependentsRetrieveRequest; +import com.merge.api.resources.hris.types.Dependent; +import com.merge.api.resources.hris.types.PaginatedDependentList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDependentsClient { + protected final ClientOptions clientOptions; + + public AsyncRawDependentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Dependent objects. + */ + public CompletableFuture> list() { + return list(DependentsListRequest.builder().build()); + } + + /** + * Returns a list of Dependent objects. + */ + public CompletableFuture> list(DependentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Dependent objects. + */ + public CompletableFuture> list( + DependentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/dependents"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeSensitiveFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_sensitive_fields", + request.getIncludeSensitiveFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedDependentList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Dependent object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, DependentsRetrieveRequest.builder().build()); + } + + /** + * Returns a Dependent object with the given id. + */ + public CompletableFuture> retrieve(String id, DependentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Dependent object with the given id. + */ + public CompletableFuture> retrieve( + String id, DependentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/dependents") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeSensitiveFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_sensitive_fields", + request.getIncludeSensitiveFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Dependent.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/dependents/DependentsClient.java b/src/main/java/com/merge/api/resources/hris/dependents/DependentsClient.java index 1b3f0fb7f..15fe50438 100644 --- a/src/main/java/com/merge/api/resources/hris/dependents/DependentsClient.java +++ b/src/main/java/com/merge/api/resources/hris/dependents/DependentsClient.java @@ -3,174 +3,69 @@ */ package com.merge.api.resources.hris.dependents; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.dependents.requests.DependentsListRequest; import com.merge.api.resources.hris.dependents.requests.DependentsRetrieveRequest; import com.merge.api.resources.hris.types.Dependent; import com.merge.api.resources.hris.types.PaginatedDependentList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class DependentsClient { protected final ClientOptions clientOptions; + private final RawDependentsClient rawClient; + public DependentsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawDependentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDependentsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Dependent objects. */ public PaginatedDependentList list() { - return list(DependentsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Dependent objects. */ public PaginatedDependentList list(DependentsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Dependent objects. */ public PaginatedDependentList list(DependentsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/dependents"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeSensitiveFields().isPresent()) { - httpUrl.addQueryParameter( - "include_sensitive_fields", - request.getIncludeSensitiveFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedDependentList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Dependent object with the given id. */ public Dependent retrieve(String id) { - return retrieve(id, DependentsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Dependent object with the given id. */ public Dependent retrieve(String id, DependentsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Dependent object with the given id. */ public Dependent retrieve(String id, DependentsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/dependents") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeSensitiveFields().isPresent()) { - httpUrl.addQueryParameter( - "include_sensitive_fields", - request.getIncludeSensitiveFields().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Dependent.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/dependents/RawDependentsClient.java b/src/main/java/com/merge/api/resources/hris/dependents/RawDependentsClient.java new file mode 100644 index 000000000..4e537563f --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/dependents/RawDependentsClient.java @@ -0,0 +1,213 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.dependents; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.dependents.requests.DependentsListRequest; +import com.merge.api.resources.hris.dependents.requests.DependentsRetrieveRequest; +import com.merge.api.resources.hris.types.Dependent; +import com.merge.api.resources.hris.types.PaginatedDependentList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDependentsClient { + protected final ClientOptions clientOptions; + + public RawDependentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Dependent objects. + */ + public MergeApiHttpResponse list() { + return list(DependentsListRequest.builder().build()); + } + + /** + * Returns a list of Dependent objects. + */ + public MergeApiHttpResponse list(DependentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Dependent objects. + */ + public MergeApiHttpResponse list( + DependentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/dependents"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeSensitiveFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_sensitive_fields", + request.getIncludeSensitiveFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedDependentList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Dependent object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, DependentsRetrieveRequest.builder().build()); + } + + /** + * Returns a Dependent object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, DependentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Dependent object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, DependentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/dependents") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeSensitiveFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_sensitive_fields", + request.getIncludeSensitiveFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Dependent.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/dependents/requests/DependentsRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/dependents/requests/DependentsRetrieveRequest.java index 5d9466ae4..a3ad18ad4 100644 --- a/src/main/java/com/merge/api/resources/hris/dependents/requests/DependentsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/dependents/requests/DependentsRetrieveRequest.java @@ -24,14 +24,18 @@ public final class DependentsRetrieveRequest { private final Optional includeSensitiveFields; + private final Optional includeShellData; + private final Map additionalProperties; private DependentsRetrieveRequest( Optional includeRemoteData, Optional includeSensitiveFields, + Optional includeShellData, Map additionalProperties) { this.includeRemoteData = includeRemoteData; this.includeSensitiveFields = includeSensitiveFields; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -51,6 +55,14 @@ public Optional getIncludeSensitiveFields() { return includeSensitiveFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +76,13 @@ public Map getAdditionalProperties() { private boolean equalTo(DependentsRetrieveRequest other) { return includeRemoteData.equals(other.includeRemoteData) - && includeSensitiveFields.equals(other.includeSensitiveFields); + && includeSensitiveFields.equals(other.includeSensitiveFields) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData, this.includeSensitiveFields); + return Objects.hash(this.includeRemoteData, this.includeSensitiveFields, this.includeShellData); } @java.lang.Override @@ -87,6 +100,8 @@ public static final class Builder { private Optional includeSensitiveFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,6 +110,7 @@ private Builder() {} public Builder from(DependentsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); includeSensitiveFields(other.getIncludeSensitiveFields()); + includeShellData(other.getIncludeShellData()); return this; } @@ -120,8 +136,20 @@ public Builder includeSensitiveFields(Boolean includeSensitiveFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public DependentsRetrieveRequest build() { - return new DependentsRetrieveRequest(includeRemoteData, includeSensitiveFields, additionalProperties); + return new DependentsRetrieveRequest( + includeRemoteData, includeSensitiveFields, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/AsyncEmployeePayrollRunsClient.java b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/AsyncEmployeePayrollRunsClient.java new file mode 100644 index 000000000..d8c6c96df --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/AsyncEmployeePayrollRunsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employeepayrollruns; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employeepayrollruns.requests.EmployeePayrollRunsListRequest; +import com.merge.api.resources.hris.employeepayrollruns.requests.EmployeePayrollRunsRetrieveRequest; +import com.merge.api.resources.hris.types.EmployeePayrollRun; +import com.merge.api.resources.hris.types.PaginatedEmployeePayrollRunList; +import java.util.concurrent.CompletableFuture; + +public class AsyncEmployeePayrollRunsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawEmployeePayrollRunsClient rawClient; + + public AsyncEmployeePayrollRunsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawEmployeePayrollRunsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawEmployeePayrollRunsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of EmployeePayrollRun objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of EmployeePayrollRun objects. + */ + public CompletableFuture list(EmployeePayrollRunsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of EmployeePayrollRun objects. + */ + public CompletableFuture list( + EmployeePayrollRunsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an EmployeePayrollRun object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an EmployeePayrollRun object with the given id. + */ + public CompletableFuture retrieve(String id, EmployeePayrollRunsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an EmployeePayrollRun object with the given id. + */ + public CompletableFuture retrieve( + String id, EmployeePayrollRunsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/AsyncRawEmployeePayrollRunsClient.java b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/AsyncRawEmployeePayrollRunsClient.java new file mode 100644 index 000000000..88b5f7094 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/AsyncRawEmployeePayrollRunsClient.java @@ -0,0 +1,265 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employeepayrollruns; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employeepayrollruns.requests.EmployeePayrollRunsListRequest; +import com.merge.api.resources.hris.employeepayrollruns.requests.EmployeePayrollRunsRetrieveRequest; +import com.merge.api.resources.hris.types.EmployeePayrollRun; +import com.merge.api.resources.hris.types.PaginatedEmployeePayrollRunList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawEmployeePayrollRunsClient { + protected final ClientOptions clientOptions; + + public AsyncRawEmployeePayrollRunsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of EmployeePayrollRun objects. + */ + public CompletableFuture> list() { + return list(EmployeePayrollRunsListRequest.builder().build()); + } + + /** + * Returns a list of EmployeePayrollRun objects. + */ + public CompletableFuture> list( + EmployeePayrollRunsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of EmployeePayrollRun objects. + */ + public CompletableFuture> list( + EmployeePayrollRunsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employee-payroll-runs"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getEndedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_after", request.getEndedAfter().get().toString(), false); + } + if (request.getEndedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_before", request.getEndedBefore().get().toString(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPayrollRunId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "payroll_run_id", request.getPayrollRunId().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedEmployeePayrollRunList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an EmployeePayrollRun object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, EmployeePayrollRunsRetrieveRequest.builder().build()); + } + + /** + * Returns an EmployeePayrollRun object with the given id. + */ + public CompletableFuture> retrieve( + String id, EmployeePayrollRunsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an EmployeePayrollRun object with the given id. + */ + public CompletableFuture> retrieve( + String id, EmployeePayrollRunsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employee-payroll-runs") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EmployeePayrollRun.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/EmployeePayrollRunsClient.java b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/EmployeePayrollRunsClient.java index 5c60c87bb..0b18c2ecf 100644 --- a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/EmployeePayrollRunsClient.java +++ b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/EmployeePayrollRunsClient.java @@ -3,154 +3,63 @@ */ package com.merge.api.resources.hris.employeepayrollruns; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.employeepayrollruns.requests.EmployeePayrollRunsListRequest; import com.merge.api.resources.hris.employeepayrollruns.requests.EmployeePayrollRunsRetrieveRequest; import com.merge.api.resources.hris.types.EmployeePayrollRun; import com.merge.api.resources.hris.types.PaginatedEmployeePayrollRunList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class EmployeePayrollRunsClient { protected final ClientOptions clientOptions; + private final RawEmployeePayrollRunsClient rawClient; + public EmployeePayrollRunsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawEmployeePayrollRunsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawEmployeePayrollRunsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of EmployeePayrollRun objects. */ public PaginatedEmployeePayrollRunList list() { - return list(EmployeePayrollRunsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of EmployeePayrollRun objects. */ public PaginatedEmployeePayrollRunList list(EmployeePayrollRunsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of EmployeePayrollRun objects. */ public PaginatedEmployeePayrollRunList list(EmployeePayrollRunsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employee-payroll-runs"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmployeeId().isPresent()) { - httpUrl.addQueryParameter("employee_id", request.getEmployeeId().get()); - } - if (request.getEndedAfter().isPresent()) { - httpUrl.addQueryParameter( - "ended_after", request.getEndedAfter().get().toString()); - } - if (request.getEndedBefore().isPresent()) { - httpUrl.addQueryParameter( - "ended_before", request.getEndedBefore().get().toString()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getPayrollRunId().isPresent()) { - httpUrl.addQueryParameter( - "payroll_run_id", request.getPayrollRunId().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getStartedAfter().isPresent()) { - httpUrl.addQueryParameter( - "started_after", request.getStartedAfter().get().toString()); - } - if (request.getStartedBefore().isPresent()) { - httpUrl.addQueryParameter( - "started_before", request.getStartedBefore().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedEmployeePayrollRunList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an EmployeePayrollRun object with the given id. */ public EmployeePayrollRun retrieve(String id) { - return retrieve(id, EmployeePayrollRunsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an EmployeePayrollRun object with the given id. */ public EmployeePayrollRun retrieve(String id, EmployeePayrollRunsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** @@ -158,40 +67,6 @@ public EmployeePayrollRun retrieve(String id, EmployeePayrollRunsRetrieveRequest */ public EmployeePayrollRun retrieve( String id, EmployeePayrollRunsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employee-payroll-runs") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EmployeePayrollRun.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/RawEmployeePayrollRunsClient.java b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/RawEmployeePayrollRunsClient.java new file mode 100644 index 000000000..9ac0b8e92 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/RawEmployeePayrollRunsClient.java @@ -0,0 +1,232 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employeepayrollruns; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employeepayrollruns.requests.EmployeePayrollRunsListRequest; +import com.merge.api.resources.hris.employeepayrollruns.requests.EmployeePayrollRunsRetrieveRequest; +import com.merge.api.resources.hris.types.EmployeePayrollRun; +import com.merge.api.resources.hris.types.PaginatedEmployeePayrollRunList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawEmployeePayrollRunsClient { + protected final ClientOptions clientOptions; + + public RawEmployeePayrollRunsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of EmployeePayrollRun objects. + */ + public MergeApiHttpResponse list() { + return list(EmployeePayrollRunsListRequest.builder().build()); + } + + /** + * Returns a list of EmployeePayrollRun objects. + */ + public MergeApiHttpResponse list(EmployeePayrollRunsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of EmployeePayrollRun objects. + */ + public MergeApiHttpResponse list( + EmployeePayrollRunsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employee-payroll-runs"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getEndedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_after", request.getEndedAfter().get().toString(), false); + } + if (request.getEndedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_before", request.getEndedBefore().get().toString(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPayrollRunId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "payroll_run_id", request.getPayrollRunId().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedEmployeePayrollRunList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an EmployeePayrollRun object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, EmployeePayrollRunsRetrieveRequest.builder().build()); + } + + /** + * Returns an EmployeePayrollRun object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, EmployeePayrollRunsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an EmployeePayrollRun object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, EmployeePayrollRunsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employee-payroll-runs") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EmployeePayrollRun.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/requests/EmployeePayrollRunsListRequest.java b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/requests/EmployeePayrollRunsListRequest.java index a5e553c7f..f70cd2a72 100644 --- a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/requests/EmployeePayrollRunsListRequest.java +++ b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/requests/EmployeePayrollRunsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.hris.employeepayrollruns.types.EmployeePayrollRunsListRequestExpand; +import com.merge.api.resources.hris.employeepayrollruns.types.EmployeePayrollRunsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EmployeePayrollRunsListRequest.Builder.class) public final class EmployeePayrollRunsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; @@ -34,8 +38,6 @@ public final class EmployeePayrollRunsListRequest { private final Optional endedBefore; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -59,13 +61,13 @@ public final class EmployeePayrollRunsListRequest { private final Map additionalProperties; private EmployeePayrollRunsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, Optional employeeId, Optional endedAfter, Optional endedBefore, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -77,13 +79,13 @@ private EmployeePayrollRunsListRequest( Optional startedAfter, Optional startedBefore, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.employeeId = employeeId; this.endedAfter = endedAfter; this.endedBefore = endedBefore; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -97,6 +99,14 @@ private EmployeePayrollRunsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -145,14 +155,6 @@ public Optional getEndedBefore() { return endedBefore; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -245,13 +247,13 @@ public Map getAdditionalProperties() { } private boolean equalTo(EmployeePayrollRunsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && employeeId.equals(other.employeeId) && endedAfter.equals(other.endedAfter) && endedBefore.equals(other.endedBefore) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -267,13 +269,13 @@ private boolean equalTo(EmployeePayrollRunsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, this.employeeId, this.endedAfter, this.endedBefore, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -297,6 +299,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); @@ -309,8 +313,6 @@ public static final class Builder { private Optional endedBefore = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -337,13 +339,13 @@ public static final class Builder { private Builder() {} public Builder from(EmployeePayrollRunsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); employeeId(other.getEmployeeId()); endedAfter(other.getEndedAfter()); endedBefore(other.getEndedBefore()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -357,6 +359,22 @@ public Builder from(EmployeePayrollRunsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(EmployeePayrollRunsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -423,17 +441,6 @@ public Builder endedBefore(OffsetDateTime endedBefore) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(EmployeePayrollRunsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -546,13 +553,13 @@ public Builder startedBefore(OffsetDateTime startedBefore) { public EmployeePayrollRunsListRequest build() { return new EmployeePayrollRunsListRequest( + expand, createdAfter, createdBefore, cursor, employeeId, endedAfter, endedBefore, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/requests/EmployeePayrollRunsRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/requests/EmployeePayrollRunsRetrieveRequest.java index aa36ef087..16baadf01 100644 --- a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/requests/EmployeePayrollRunsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/requests/EmployeePayrollRunsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.hris.employeepayrollruns.types.EmployeePayrollRunsRetrieveRequestExpand; +import com.merge.api.resources.hris.employeepayrollruns.types.EmployeePayrollRunsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EmployeePayrollRunsRetrieveRequest.Builder.class) public final class EmployeePayrollRunsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private EmployeePayrollRunsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private EmployeePayrollRunsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -65,12 +79,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(EmployeePayrollRunsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -84,10 +100,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -96,20 +114,26 @@ private Builder() {} public Builder from(EmployeePayrollRunsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(EmployeePayrollRunsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(EmployeePayrollRunsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -121,8 +145,20 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public EmployeePayrollRunsRetrieveRequest build() { - return new EmployeePayrollRunsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new EmployeePayrollRunsRetrieveRequest( + expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsListRequestExpand.java b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsListRequestExpand.java deleted file mode 100644 index e8746e79c..000000000 --- a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.employeepayrollruns.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum EmployeePayrollRunsListRequestExpand { - EMPLOYEE("employee"), - - EMPLOYEE_PAYROLL_RUN("employee,payroll_run"), - - PAYROLL_RUN("payroll_run"); - - private final String value; - - EmployeePayrollRunsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsListRequestExpandItem.java new file mode 100644 index 000000000..529280ffa --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employeepayrollruns.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmployeePayrollRunsListRequestExpandItem { + EMPLOYEE("employee"), + + PAYROLL_RUN("payroll_run"); + + private final String value; + + EmployeePayrollRunsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsRetrieveRequestExpand.java deleted file mode 100644 index facc3cefd..000000000 --- a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsRetrieveRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.employeepayrollruns.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum EmployeePayrollRunsRetrieveRequestExpand { - EMPLOYEE("employee"), - - EMPLOYEE_PAYROLL_RUN("employee,payroll_run"), - - PAYROLL_RUN("payroll_run"); - - private final String value; - - EmployeePayrollRunsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..282a7a026 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employeepayrollruns/types/EmployeePayrollRunsRetrieveRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employeepayrollruns.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmployeePayrollRunsRetrieveRequestExpandItem { + EMPLOYEE("employee"), + + PAYROLL_RUN("payroll_run"); + + private final String value; + + EmployeePayrollRunsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employees/AsyncEmployeesClient.java b/src/main/java/com/merge/api/resources/hris/employees/AsyncEmployeesClient.java new file mode 100644 index 000000000..af9ca4046 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employees/AsyncEmployeesClient.java @@ -0,0 +1,120 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employees; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employees.requests.EmployeeEndpointRequest; +import com.merge.api.resources.hris.employees.requests.EmployeesListRequest; +import com.merge.api.resources.hris.employees.requests.EmployeesRetrieveRequest; +import com.merge.api.resources.hris.types.Employee; +import com.merge.api.resources.hris.types.EmployeeResponse; +import com.merge.api.resources.hris.types.IgnoreCommonModelRequest; +import com.merge.api.resources.hris.types.MetaResponse; +import com.merge.api.resources.hris.types.PaginatedEmployeeList; +import java.util.concurrent.CompletableFuture; + +public class AsyncEmployeesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawEmployeesClient rawClient; + + public AsyncEmployeesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawEmployeesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawEmployeesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture list(EmployeesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture list(EmployeesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Employee object with the given values. + */ + public CompletableFuture create(EmployeeEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Employee object with the given values. + */ + public CompletableFuture create(EmployeeEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture retrieve(String id, EmployeesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture retrieve( + String id, EmployeesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture ignoreCreate(String modelId, IgnoreCommonModelRequest request) { + return this.rawClient.ignoreCreate(modelId, request).thenApply(response -> response.body()); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + return this.rawClient.ignoreCreate(modelId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Employee POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Employee POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employees/AsyncRawEmployeesClient.java b/src/main/java/com/merge/api/resources/hris/employees/AsyncRawEmployeesClient.java new file mode 100644 index 000000000..9f1714539 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employees/AsyncRawEmployeesClient.java @@ -0,0 +1,562 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employees; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employees.requests.EmployeeEndpointRequest; +import com.merge.api.resources.hris.employees.requests.EmployeesListRequest; +import com.merge.api.resources.hris.employees.requests.EmployeesRetrieveRequest; +import com.merge.api.resources.hris.types.Employee; +import com.merge.api.resources.hris.types.EmployeeResponse; +import com.merge.api.resources.hris.types.IgnoreCommonModelRequest; +import com.merge.api.resources.hris.types.MetaResponse; +import com.merge.api.resources.hris.types.PaginatedEmployeeList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawEmployeesClient { + protected final ClientOptions clientOptions; + + public AsyncRawEmployeesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture> list() { + return list(EmployeesListRequest.builder().build()); + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture> list(EmployeesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Employee objects. + */ + public CompletableFuture> list( + EmployeesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employees"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getDisplayFullName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_full_name", request.getDisplayFullName().get(), false); + } + if (request.getEmploymentStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "employment_status", + request.getEmploymentStatus().get().toString(), + false); + } + if (request.getEmploymentType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employment_type", request.getEmploymentType().get(), false); + } + if (request.getFirstName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "first_name", request.getFirstName().get(), false); + } + if (request.getGroups().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "groups", request.getGroups().get(), false); + } + if (request.getHomeLocationId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "home_location_id", request.getHomeLocationId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeSensitiveFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_sensitive_fields", + request.getIncludeSensitiveFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getJobTitle().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "job_title", request.getJobTitle().get(), false); + } + if (request.getLastName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "last_name", request.getLastName().get(), false); + } + if (request.getManagerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "manager_id", request.getManagerId().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPayGroupId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "pay_group_id", request.getPayGroupId().get(), false); + } + if (request.getPersonalEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "personal_email", request.getPersonalEmail().get(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + if (request.getTeamId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "team_id", request.getTeamId().get(), false); + } + if (request.getTerminatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "terminated_after", + request.getTerminatedAfter().get().toString(), + false); + } + if (request.getTerminatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "terminated_before", + request.getTerminatedBefore().get().toString(), + false); + } + if (request.getWorkEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "work_email", request.getWorkEmail().get(), false); + } + if (request.getWorkLocationId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "work_location_id", request.getWorkLocationId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEmployeeList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Employee object with the given values. + */ + public CompletableFuture> create(EmployeeEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Employee object with the given values. + */ + public CompletableFuture> create( + EmployeeEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employees"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EmployeeResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, EmployeesRetrieveRequest.builder().build()); + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture> retrieve(String id, EmployeesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Employee object with the given id. + */ + public CompletableFuture> retrieve( + String id, EmployeesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employees") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeSensitiveFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_sensitive_fields", + request.getIncludeSensitiveFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Employee.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture> ignoreCreate( + String modelId, IgnoreCommonModelRequest request) { + return ignoreCreate(modelId, request, null); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public CompletableFuture> ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employees/ignore") + .addPathSegment(modelId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Employee POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Employee POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employees/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employees/EmployeesClient.java b/src/main/java/com/merge/api/resources/hris/employees/EmployeesClient.java index 6fc7645e0..4de0fce66 100644 --- a/src/main/java/com/merge/api/resources/hris/employees/EmployeesClient.java +++ b/src/main/java/com/merge/api/resources/hris/employees/EmployeesClient.java @@ -3,417 +3,115 @@ */ package com.merge.api.resources.hris.employees; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.employees.requests.EmployeeEndpointRequest; import com.merge.api.resources.hris.employees.requests.EmployeesListRequest; import com.merge.api.resources.hris.employees.requests.EmployeesRetrieveRequest; -import com.merge.api.resources.hris.employees.requests.IgnoreCommonModelRequest; import com.merge.api.resources.hris.types.Employee; import com.merge.api.resources.hris.types.EmployeeResponse; +import com.merge.api.resources.hris.types.IgnoreCommonModelRequest; import com.merge.api.resources.hris.types.MetaResponse; import com.merge.api.resources.hris.types.PaginatedEmployeeList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class EmployeesClient { protected final ClientOptions clientOptions; + private final RawEmployeesClient rawClient; + public EmployeesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawEmployeesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawEmployeesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Employee objects. */ public PaginatedEmployeeList list() { - return list(EmployeesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Employee objects. */ public PaginatedEmployeeList list(EmployeesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Employee objects. */ public PaginatedEmployeeList list(EmployeesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employees"); - if (request.getCompanyId().isPresent()) { - httpUrl.addQueryParameter("company_id", request.getCompanyId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getDisplayFullName().isPresent()) { - httpUrl.addQueryParameter( - "display_full_name", request.getDisplayFullName().get()); - } - if (request.getEmploymentStatus().isPresent()) { - httpUrl.addQueryParameter( - "employment_status", request.getEmploymentStatus().get().toString()); - } - if (request.getEmploymentType().isPresent()) { - httpUrl.addQueryParameter( - "employment_type", request.getEmploymentType().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getFirstName().isPresent()) { - httpUrl.addQueryParameter("first_name", request.getFirstName().get()); - } - if (request.getGroups().isPresent()) { - httpUrl.addQueryParameter("groups", request.getGroups().get()); - } - if (request.getHomeLocationId().isPresent()) { - httpUrl.addQueryParameter( - "home_location_id", request.getHomeLocationId().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeSensitiveFields().isPresent()) { - httpUrl.addQueryParameter( - "include_sensitive_fields", - request.getIncludeSensitiveFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getJobTitle().isPresent()) { - httpUrl.addQueryParameter("job_title", request.getJobTitle().get()); - } - if (request.getLastName().isPresent()) { - httpUrl.addQueryParameter("last_name", request.getLastName().get()); - } - if (request.getManagerId().isPresent()) { - httpUrl.addQueryParameter("manager_id", request.getManagerId().get()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getPayGroupId().isPresent()) { - httpUrl.addQueryParameter("pay_group_id", request.getPayGroupId().get()); - } - if (request.getPersonalEmail().isPresent()) { - httpUrl.addQueryParameter( - "personal_email", request.getPersonalEmail().get()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - if (request.getStartedAfter().isPresent()) { - httpUrl.addQueryParameter( - "started_after", request.getStartedAfter().get().toString()); - } - if (request.getStartedBefore().isPresent()) { - httpUrl.addQueryParameter( - "started_before", request.getStartedBefore().get().toString()); - } - if (request.getTeamId().isPresent()) { - httpUrl.addQueryParameter("team_id", request.getTeamId().get()); - } - if (request.getTerminatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "terminated_after", request.getTerminatedAfter().get().toString()); - } - if (request.getTerminatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "terminated_before", request.getTerminatedBefore().get().toString()); - } - if (request.getWorkEmail().isPresent()) { - httpUrl.addQueryParameter("work_email", request.getWorkEmail().get()); - } - if (request.getWorkLocationId().isPresent()) { - httpUrl.addQueryParameter( - "work_location_id", request.getWorkLocationId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEmployeeList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates an Employee object with the given values. */ public EmployeeResponse create(EmployeeEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates an Employee object with the given values. */ public EmployeeResponse create(EmployeeEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employees"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EmployeeResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Employee object with the given id. */ public Employee retrieve(String id) { - return retrieve(id, EmployeesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Employee object with the given id. */ public Employee retrieve(String id, EmployeesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Employee object with the given id. */ public Employee retrieve(String id, EmployeesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employees") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeSensitiveFields().isPresent()) { - httpUrl.addQueryParameter( - "include_sensitive_fields", - request.getIncludeSensitiveFields().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Employee.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. */ public void ignoreCreate(String modelId, IgnoreCommonModelRequest request) { - ignoreCreate(modelId, request, null); + this.rawClient.ignoreCreate(modelId, request).body(); } /** * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. */ public void ignoreCreate(String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employees/ignore") - .addPathSegment(modelId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + this.rawClient.ignoreCreate(modelId, request, requestOptions).body(); } /** * Returns metadata for Employee POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Employee POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employees/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/employees/RawEmployeesClient.java b/src/main/java/com/merge/api/resources/hris/employees/RawEmployeesClient.java new file mode 100644 index 000000000..a8de4ab9b --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employees/RawEmployeesClient.java @@ -0,0 +1,490 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employees; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employees.requests.EmployeeEndpointRequest; +import com.merge.api.resources.hris.employees.requests.EmployeesListRequest; +import com.merge.api.resources.hris.employees.requests.EmployeesRetrieveRequest; +import com.merge.api.resources.hris.types.Employee; +import com.merge.api.resources.hris.types.EmployeeResponse; +import com.merge.api.resources.hris.types.IgnoreCommonModelRequest; +import com.merge.api.resources.hris.types.MetaResponse; +import com.merge.api.resources.hris.types.PaginatedEmployeeList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawEmployeesClient { + protected final ClientOptions clientOptions; + + public RawEmployeesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Employee objects. + */ + public MergeApiHttpResponse list() { + return list(EmployeesListRequest.builder().build()); + } + + /** + * Returns a list of Employee objects. + */ + public MergeApiHttpResponse list(EmployeesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Employee objects. + */ + public MergeApiHttpResponse list( + EmployeesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employees"); + if (request.getCompanyId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "company_id", request.getCompanyId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getDisplayFullName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "display_full_name", request.getDisplayFullName().get(), false); + } + if (request.getEmploymentStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "employment_status", + request.getEmploymentStatus().get().toString(), + false); + } + if (request.getEmploymentType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employment_type", request.getEmploymentType().get(), false); + } + if (request.getFirstName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "first_name", request.getFirstName().get(), false); + } + if (request.getGroups().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "groups", request.getGroups().get(), false); + } + if (request.getHomeLocationId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "home_location_id", request.getHomeLocationId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeSensitiveFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_sensitive_fields", + request.getIncludeSensitiveFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getJobTitle().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "job_title", request.getJobTitle().get(), false); + } + if (request.getLastName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "last_name", request.getLastName().get(), false); + } + if (request.getManagerId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "manager_id", request.getManagerId().get(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPayGroupId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "pay_group_id", request.getPayGroupId().get(), false); + } + if (request.getPersonalEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "personal_email", request.getPersonalEmail().get(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + if (request.getTeamId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "team_id", request.getTeamId().get(), false); + } + if (request.getTerminatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "terminated_after", + request.getTerminatedAfter().get().toString(), + false); + } + if (request.getTerminatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "terminated_before", + request.getTerminatedBefore().get().toString(), + false); + } + if (request.getWorkEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "work_email", request.getWorkEmail().get(), false); + } + if (request.getWorkLocationId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "work_location_id", request.getWorkLocationId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEmployeeList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Employee object with the given values. + */ + public MergeApiHttpResponse create(EmployeeEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Employee object with the given values. + */ + public MergeApiHttpResponse create( + EmployeeEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employees"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EmployeeResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Employee object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, EmployeesRetrieveRequest.builder().build()); + } + + /** + * Returns an Employee object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, EmployeesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Employee object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, EmployeesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employees") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeSensitiveFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_sensitive_fields", + request.getIncludeSensitiveFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Employee.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public MergeApiHttpResponse ignoreCreate(String modelId, IgnoreCommonModelRequest request) { + return ignoreCreate(modelId, request, null); + } + + /** + * Ignores a specific row based on the model_id in the url. These records will have their properties set to null, and will not be updated in future syncs. The "reason" and "message" fields in the request body will be stored for audit purposes. + */ + public MergeApiHttpResponse ignoreCreate( + String modelId, IgnoreCommonModelRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employees/ignore") + .addPathSegment(modelId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Employee POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Employee POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employees/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employees/requests/EmployeesListRequest.java b/src/main/java/com/merge/api/resources/hris/employees/requests/EmployeesListRequest.java index 55c26a0f4..89a15981d 100644 --- a/src/main/java/com/merge/api/resources/hris/employees/requests/EmployeesListRequest.java +++ b/src/main/java/com/merge/api/resources/hris/employees/requests/EmployeesListRequest.java @@ -13,11 +13,13 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import com.merge.api.resources.hris.employees.types.EmployeesListRequestEmploymentStatus; -import com.merge.api.resources.hris.employees.types.EmployeesListRequestExpand; +import com.merge.api.resources.hris.employees.types.EmployeesListRequestExpandItem; import com.merge.api.resources.hris.employees.types.EmployeesListRequestRemoteFields; import com.merge.api.resources.hris.employees.types.EmployeesListRequestShowEnumOrigins; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -25,6 +27,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EmployeesListRequest.Builder.class) public final class EmployeesListRequest { + private final Optional> expand; + private final Optional companyId; private final Optional createdAfter; @@ -39,8 +43,6 @@ public final class EmployeesListRequest { private final Optional employmentType; - private final Optional expand; - private final Optional firstName; private final Optional groups; @@ -94,6 +96,7 @@ public final class EmployeesListRequest { private final Map additionalProperties; private EmployeesListRequest( + Optional> expand, Optional companyId, Optional createdAfter, Optional createdBefore, @@ -101,7 +104,6 @@ private EmployeesListRequest( Optional displayFullName, Optional employmentStatus, Optional employmentType, - Optional expand, Optional firstName, Optional groups, Optional homeLocationId, @@ -128,6 +130,7 @@ private EmployeesListRequest( Optional workEmail, Optional workLocationId, Map additionalProperties) { + this.expand = expand; this.companyId = companyId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; @@ -135,7 +138,6 @@ private EmployeesListRequest( this.displayFullName = displayFullName; this.employmentStatus = employmentStatus; this.employmentType = employmentType; - this.expand = expand; this.firstName = firstName; this.groups = groups; this.homeLocationId = homeLocationId; @@ -164,6 +166,14 @@ private EmployeesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return employees for this company. */ @@ -225,14 +235,6 @@ public Optional getEmploymentType() { return employmentType; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return If provided, will only return employees with this first name. */ @@ -445,14 +447,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(EmployeesListRequest other) { - return companyId.equals(other.companyId) + return expand.equals(other.expand) + && companyId.equals(other.companyId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && displayFullName.equals(other.displayFullName) && employmentStatus.equals(other.employmentStatus) && employmentType.equals(other.employmentType) - && expand.equals(other.expand) && firstName.equals(other.firstName) && groups.equals(other.groups) && homeLocationId.equals(other.homeLocationId) @@ -483,6 +485,7 @@ private boolean equalTo(EmployeesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.companyId, this.createdAfter, this.createdBefore, @@ -490,7 +493,6 @@ public int hashCode() { this.displayFullName, this.employmentStatus, this.employmentType, - this.expand, this.firstName, this.groups, this.homeLocationId, @@ -529,6 +531,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional companyId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -543,8 +547,6 @@ public static final class Builder { private Optional employmentType = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional firstName = Optional.empty(); private Optional groups = Optional.empty(); @@ -601,6 +603,7 @@ public static final class Builder { private Builder() {} public Builder from(EmployeesListRequest other) { + expand(other.getExpand()); companyId(other.getCompanyId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); @@ -608,7 +611,6 @@ public Builder from(EmployeesListRequest other) { displayFullName(other.getDisplayFullName()); employmentStatus(other.getEmploymentStatus()); employmentType(other.getEmploymentType()); - expand(other.getExpand()); firstName(other.getFirstName()); groups(other.getGroups()); homeLocationId(other.getHomeLocationId()); @@ -637,6 +639,22 @@ public Builder from(EmployeesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(EmployeesListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "company_id", nulls = Nulls.SKIP) public Builder companyId(Optional companyId) { this.companyId = companyId; @@ -714,17 +732,6 @@ public Builder employmentType(String employmentType) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(EmployeesListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "first_name", nulls = Nulls.SKIP) public Builder firstName(Optional firstName) { this.firstName = firstName; @@ -1002,6 +1009,7 @@ public Builder workLocationId(String workLocationId) { public EmployeesListRequest build() { return new EmployeesListRequest( + expand, companyId, createdAfter, createdBefore, @@ -1009,7 +1017,6 @@ public EmployeesListRequest build() { displayFullName, employmentStatus, employmentType, - expand, firstName, groups, homeLocationId, diff --git a/src/main/java/com/merge/api/resources/hris/employees/requests/EmployeesRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/employees/requests/EmployeesRetrieveRequest.java index b9b16a87d..f8cdb3946 100644 --- a/src/main/java/com/merge/api/resources/hris/employees/requests/EmployeesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/employees/requests/EmployeesRetrieveRequest.java @@ -12,10 +12,12 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.hris.employees.types.EmployeesRetrieveRequestExpand; +import com.merge.api.resources.hris.employees.types.EmployeesRetrieveRequestExpandItem; import com.merge.api.resources.hris.employees.types.EmployeesRetrieveRequestRemoteFields; import com.merge.api.resources.hris.employees.types.EmployeesRetrieveRequestShowEnumOrigins; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,12 +25,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EmployeesRetrieveRequest.Builder.class) public final class EmployeesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeSensitiveFields; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -36,15 +40,17 @@ public final class EmployeesRetrieveRequest { private final Map additionalProperties; private EmployeesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeSensitiveFields, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeSensitiveFields = includeSensitiveFields; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -54,7 +60,7 @@ private EmployeesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -74,6 +80,14 @@ public Optional getIncludeSensitiveFields() { return includeSensitiveFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -105,6 +119,7 @@ private boolean equalTo(EmployeesRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) && includeSensitiveFields.equals(other.includeSensitiveFields) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @@ -115,6 +130,7 @@ public int hashCode() { this.expand, this.includeRemoteData, this.includeSensitiveFields, + this.includeShellData, this.remoteFields, this.showEnumOrigins); } @@ -130,12 +146,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeSensitiveFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -149,22 +167,28 @@ public Builder from(EmployeesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeSensitiveFields(other.getIncludeSensitiveFields()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(EmployeesRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(EmployeesRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -187,6 +211,17 @@ public Builder includeSensitiveFields(Boolean includeSensitiveFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -214,6 +249,7 @@ public EmployeesRetrieveRequest build() { expand, includeRemoteData, includeSensitiveFields, + includeShellData, remoteFields, showEnumOrigins, additionalProperties); diff --git a/src/main/java/com/merge/api/resources/hris/employees/requests/IgnoreCommonModelRequest.java b/src/main/java/com/merge/api/resources/hris/employees/requests/IgnoreCommonModelRequest.java deleted file mode 100644 index 7675eca84..000000000 --- a/src/main/java/com/merge/api/resources/hris/employees/requests/IgnoreCommonModelRequest.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.employees.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.hris.employees.types.IgnoreCommonModelRequestReason; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = IgnoreCommonModelRequest.Builder.class) -public final class IgnoreCommonModelRequest { - private final IgnoreCommonModelRequestReason reason; - - private final Optional message; - - private final Map additionalProperties; - - private IgnoreCommonModelRequest( - IgnoreCommonModelRequestReason reason, Optional message, Map additionalProperties) { - this.reason = reason; - this.message = message; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("reason") - public IgnoreCommonModelRequestReason getReason() { - return reason; - } - - @JsonProperty("message") - public Optional getMessage() { - return message; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IgnoreCommonModelRequest && equalTo((IgnoreCommonModelRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(IgnoreCommonModelRequest other) { - return reason.equals(other.reason) && message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.reason, this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ReasonStage builder() { - return new Builder(); - } - - public interface ReasonStage { - _FinalStage reason(@NotNull IgnoreCommonModelRequestReason reason); - - Builder from(IgnoreCommonModelRequest other); - } - - public interface _FinalStage { - IgnoreCommonModelRequest build(); - - _FinalStage message(Optional message); - - _FinalStage message(String message); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ReasonStage, _FinalStage { - private IgnoreCommonModelRequestReason reason; - - private Optional message = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(IgnoreCommonModelRequest other) { - reason(other.getReason()); - message(other.getMessage()); - return this; - } - - @java.lang.Override - @JsonSetter("reason") - public _FinalStage reason(@NotNull IgnoreCommonModelRequestReason reason) { - this.reason = reason; - return this; - } - - @java.lang.Override - public _FinalStage message(String message) { - this.message = Optional.ofNullable(message); - return this; - } - - @java.lang.Override - @JsonSetter(value = "message", nulls = Nulls.SKIP) - public _FinalStage message(Optional message) { - this.message = message; - return this; - } - - @java.lang.Override - public IgnoreCommonModelRequest build() { - return new IgnoreCommonModelRequest(reason, message, additionalProperties); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesListRequestExpand.java b/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesListRequestExpand.java deleted file mode 100644 index f92f35628..000000000 --- a/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesListRequestExpand.java +++ /dev/null @@ -1,560 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.employees.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum EmployeesListRequestExpand { - COMPANY("company"), - - COMPANY_PAY_GROUP("company,pay_group"), - - EMPLOYMENTS("employments"), - - EMPLOYMENTS_COMPANY("employments,company"), - - EMPLOYMENTS_COMPANY_PAY_GROUP("employments,company,pay_group"), - - EMPLOYMENTS_GROUPS("employments,groups"), - - EMPLOYMENTS_GROUPS_COMPANY("employments,groups,company"), - - EMPLOYMENTS_GROUPS_COMPANY_PAY_GROUP("employments,groups,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION("employments,groups,home_location"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_COMPANY("employments,groups,home_location,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_COMPANY_PAY_GROUP("employments,groups,home_location,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER("employments,groups,home_location,manager"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_COMPANY("employments,groups,home_location,manager,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_COMPANY_PAY_GROUP( - "employments,groups,home_location,manager,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_PAY_GROUP("employments,groups,home_location,manager,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_TEAM("employments,groups,home_location,manager,team"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_TEAM_COMPANY("employments,groups,home_location,manager,team,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,groups,home_location,manager,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_TEAM_PAY_GROUP("employments,groups,home_location,manager,team,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_PAY_GROUP("employments,groups,home_location,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_TEAM("employments,groups,home_location,team"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_TEAM_COMPANY("employments,groups,home_location,team,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_TEAM_COMPANY_PAY_GROUP("employments,groups,home_location,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_TEAM_PAY_GROUP("employments,groups,home_location,team,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION("employments,groups,home_location,work_location"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_COMPANY("employments,groups,home_location,work_location,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_COMPANY_PAY_GROUP( - "employments,groups,home_location,work_location,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER("employments,groups,home_location,work_location,manager"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY( - "employments,groups,home_location,work_location,manager,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP( - "employments,groups,home_location,work_location,manager,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_PAY_GROUP( - "employments,groups,home_location,work_location,manager,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM( - "employments,groups,home_location,work_location,manager,team"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY( - "employments,groups,home_location,work_location,manager,team,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,groups,home_location,work_location,manager,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP( - "employments,groups,home_location,work_location,manager,team,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_PAY_GROUP( - "employments,groups,home_location,work_location,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM("employments,groups,home_location,work_location,team"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY( - "employments,groups,home_location,work_location,team,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP( - "employments,groups,home_location,work_location,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_PAY_GROUP( - "employments,groups,home_location,work_location,team,pay_group"), - - EMPLOYMENTS_GROUPS_MANAGER("employments,groups,manager"), - - EMPLOYMENTS_GROUPS_MANAGER_COMPANY("employments,groups,manager,company"), - - EMPLOYMENTS_GROUPS_MANAGER_COMPANY_PAY_GROUP("employments,groups,manager,company,pay_group"), - - EMPLOYMENTS_GROUPS_MANAGER_PAY_GROUP("employments,groups,manager,pay_group"), - - EMPLOYMENTS_GROUPS_MANAGER_TEAM("employments,groups,manager,team"), - - EMPLOYMENTS_GROUPS_MANAGER_TEAM_COMPANY("employments,groups,manager,team,company"), - - EMPLOYMENTS_GROUPS_MANAGER_TEAM_COMPANY_PAY_GROUP("employments,groups,manager,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_MANAGER_TEAM_PAY_GROUP("employments,groups,manager,team,pay_group"), - - EMPLOYMENTS_GROUPS_PAY_GROUP("employments,groups,pay_group"), - - EMPLOYMENTS_GROUPS_TEAM("employments,groups,team"), - - EMPLOYMENTS_GROUPS_TEAM_COMPANY("employments,groups,team,company"), - - EMPLOYMENTS_GROUPS_TEAM_COMPANY_PAY_GROUP("employments,groups,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_TEAM_PAY_GROUP("employments,groups,team,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION("employments,groups,work_location"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_COMPANY("employments,groups,work_location,company"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_COMPANY_PAY_GROUP("employments,groups,work_location,company,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER("employments,groups,work_location,manager"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_COMPANY("employments,groups,work_location,manager,company"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP( - "employments,groups,work_location,manager,company,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_PAY_GROUP("employments,groups,work_location,manager,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_TEAM("employments,groups,work_location,manager,team"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_TEAM_COMPANY("employments,groups,work_location,manager,team,company"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,groups,work_location,manager,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP("employments,groups,work_location,manager,team,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_PAY_GROUP("employments,groups,work_location,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_TEAM("employments,groups,work_location,team"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_TEAM_COMPANY("employments,groups,work_location,team,company"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP("employments,groups,work_location,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_TEAM_PAY_GROUP("employments,groups,work_location,team,pay_group"), - - EMPLOYMENTS_HOME_LOCATION("employments,home_location"), - - EMPLOYMENTS_HOME_LOCATION_COMPANY("employments,home_location,company"), - - EMPLOYMENTS_HOME_LOCATION_COMPANY_PAY_GROUP("employments,home_location,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER("employments,home_location,manager"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_COMPANY("employments,home_location,manager,company"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_COMPANY_PAY_GROUP("employments,home_location,manager,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_PAY_GROUP("employments,home_location,manager,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_TEAM("employments,home_location,manager,team"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_TEAM_COMPANY("employments,home_location,manager,team,company"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,home_location,manager,team,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_TEAM_PAY_GROUP("employments,home_location,manager,team,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_PAY_GROUP("employments,home_location,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_TEAM("employments,home_location,team"), - - EMPLOYMENTS_HOME_LOCATION_TEAM_COMPANY("employments,home_location,team,company"), - - EMPLOYMENTS_HOME_LOCATION_TEAM_COMPANY_PAY_GROUP("employments,home_location,team,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_TEAM_PAY_GROUP("employments,home_location,team,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION("employments,home_location,work_location"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_COMPANY("employments,home_location,work_location,company"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_COMPANY_PAY_GROUP( - "employments,home_location,work_location,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER("employments,home_location,work_location,manager"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY("employments,home_location,work_location,manager,company"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP( - "employments,home_location,work_location,manager,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_PAY_GROUP( - "employments,home_location,work_location,manager,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM("employments,home_location,work_location,manager,team"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY( - "employments,home_location,work_location,manager,team,company"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,home_location,work_location,manager,team,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP( - "employments,home_location,work_location,manager,team,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_PAY_GROUP("employments,home_location,work_location,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_TEAM("employments,home_location,work_location,team"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY("employments,home_location,work_location,team,company"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP( - "employments,home_location,work_location,team,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_TEAM_PAY_GROUP("employments,home_location,work_location,team,pay_group"), - - EMPLOYMENTS_MANAGER("employments,manager"), - - EMPLOYMENTS_MANAGER_COMPANY("employments,manager,company"), - - EMPLOYMENTS_MANAGER_COMPANY_PAY_GROUP("employments,manager,company,pay_group"), - - EMPLOYMENTS_MANAGER_PAY_GROUP("employments,manager,pay_group"), - - EMPLOYMENTS_MANAGER_TEAM("employments,manager,team"), - - EMPLOYMENTS_MANAGER_TEAM_COMPANY("employments,manager,team,company"), - - EMPLOYMENTS_MANAGER_TEAM_COMPANY_PAY_GROUP("employments,manager,team,company,pay_group"), - - EMPLOYMENTS_MANAGER_TEAM_PAY_GROUP("employments,manager,team,pay_group"), - - EMPLOYMENTS_PAY_GROUP("employments,pay_group"), - - EMPLOYMENTS_TEAM("employments,team"), - - EMPLOYMENTS_TEAM_COMPANY("employments,team,company"), - - EMPLOYMENTS_TEAM_COMPANY_PAY_GROUP("employments,team,company,pay_group"), - - EMPLOYMENTS_TEAM_PAY_GROUP("employments,team,pay_group"), - - EMPLOYMENTS_WORK_LOCATION("employments,work_location"), - - EMPLOYMENTS_WORK_LOCATION_COMPANY("employments,work_location,company"), - - EMPLOYMENTS_WORK_LOCATION_COMPANY_PAY_GROUP("employments,work_location,company,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER("employments,work_location,manager"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_COMPANY("employments,work_location,manager,company"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP("employments,work_location,manager,company,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_PAY_GROUP("employments,work_location,manager,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_TEAM("employments,work_location,manager,team"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_TEAM_COMPANY("employments,work_location,manager,team,company"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,work_location,manager,team,company,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP("employments,work_location,manager,team,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_PAY_GROUP("employments,work_location,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_TEAM("employments,work_location,team"), - - EMPLOYMENTS_WORK_LOCATION_TEAM_COMPANY("employments,work_location,team,company"), - - EMPLOYMENTS_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP("employments,work_location,team,company,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_TEAM_PAY_GROUP("employments,work_location,team,pay_group"), - - GROUPS("groups"), - - GROUPS_COMPANY("groups,company"), - - GROUPS_COMPANY_PAY_GROUP("groups,company,pay_group"), - - GROUPS_HOME_LOCATION("groups,home_location"), - - GROUPS_HOME_LOCATION_COMPANY("groups,home_location,company"), - - GROUPS_HOME_LOCATION_COMPANY_PAY_GROUP("groups,home_location,company,pay_group"), - - GROUPS_HOME_LOCATION_MANAGER("groups,home_location,manager"), - - GROUPS_HOME_LOCATION_MANAGER_COMPANY("groups,home_location,manager,company"), - - GROUPS_HOME_LOCATION_MANAGER_COMPANY_PAY_GROUP("groups,home_location,manager,company,pay_group"), - - GROUPS_HOME_LOCATION_MANAGER_PAY_GROUP("groups,home_location,manager,pay_group"), - - GROUPS_HOME_LOCATION_MANAGER_TEAM("groups,home_location,manager,team"), - - GROUPS_HOME_LOCATION_MANAGER_TEAM_COMPANY("groups,home_location,manager,team,company"), - - GROUPS_HOME_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP("groups,home_location,manager,team,company,pay_group"), - - GROUPS_HOME_LOCATION_MANAGER_TEAM_PAY_GROUP("groups,home_location,manager,team,pay_group"), - - GROUPS_HOME_LOCATION_PAY_GROUP("groups,home_location,pay_group"), - - GROUPS_HOME_LOCATION_TEAM("groups,home_location,team"), - - GROUPS_HOME_LOCATION_TEAM_COMPANY("groups,home_location,team,company"), - - GROUPS_HOME_LOCATION_TEAM_COMPANY_PAY_GROUP("groups,home_location,team,company,pay_group"), - - GROUPS_HOME_LOCATION_TEAM_PAY_GROUP("groups,home_location,team,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION("groups,home_location,work_location"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_COMPANY("groups,home_location,work_location,company"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_COMPANY_PAY_GROUP("groups,home_location,work_location,company,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER("groups,home_location,work_location,manager"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY("groups,home_location,work_location,manager,company"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP( - "groups,home_location,work_location,manager,company,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_PAY_GROUP("groups,home_location,work_location,manager,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM("groups,home_location,work_location,manager,team"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY("groups,home_location,work_location,manager,team,company"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "groups,home_location,work_location,manager,team,company,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP( - "groups,home_location,work_location,manager,team,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_PAY_GROUP("groups,home_location,work_location,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM("groups,home_location,work_location,team"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY("groups,home_location,work_location,team,company"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP( - "groups,home_location,work_location,team,company,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_PAY_GROUP("groups,home_location,work_location,team,pay_group"), - - GROUPS_MANAGER("groups,manager"), - - GROUPS_MANAGER_COMPANY("groups,manager,company"), - - GROUPS_MANAGER_COMPANY_PAY_GROUP("groups,manager,company,pay_group"), - - GROUPS_MANAGER_PAY_GROUP("groups,manager,pay_group"), - - GROUPS_MANAGER_TEAM("groups,manager,team"), - - GROUPS_MANAGER_TEAM_COMPANY("groups,manager,team,company"), - - GROUPS_MANAGER_TEAM_COMPANY_PAY_GROUP("groups,manager,team,company,pay_group"), - - GROUPS_MANAGER_TEAM_PAY_GROUP("groups,manager,team,pay_group"), - - GROUPS_PAY_GROUP("groups,pay_group"), - - GROUPS_TEAM("groups,team"), - - GROUPS_TEAM_COMPANY("groups,team,company"), - - GROUPS_TEAM_COMPANY_PAY_GROUP("groups,team,company,pay_group"), - - GROUPS_TEAM_PAY_GROUP("groups,team,pay_group"), - - GROUPS_WORK_LOCATION("groups,work_location"), - - GROUPS_WORK_LOCATION_COMPANY("groups,work_location,company"), - - GROUPS_WORK_LOCATION_COMPANY_PAY_GROUP("groups,work_location,company,pay_group"), - - GROUPS_WORK_LOCATION_MANAGER("groups,work_location,manager"), - - GROUPS_WORK_LOCATION_MANAGER_COMPANY("groups,work_location,manager,company"), - - GROUPS_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP("groups,work_location,manager,company,pay_group"), - - GROUPS_WORK_LOCATION_MANAGER_PAY_GROUP("groups,work_location,manager,pay_group"), - - GROUPS_WORK_LOCATION_MANAGER_TEAM("groups,work_location,manager,team"), - - GROUPS_WORK_LOCATION_MANAGER_TEAM_COMPANY("groups,work_location,manager,team,company"), - - GROUPS_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP("groups,work_location,manager,team,company,pay_group"), - - GROUPS_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP("groups,work_location,manager,team,pay_group"), - - GROUPS_WORK_LOCATION_PAY_GROUP("groups,work_location,pay_group"), - - GROUPS_WORK_LOCATION_TEAM("groups,work_location,team"), - - GROUPS_WORK_LOCATION_TEAM_COMPANY("groups,work_location,team,company"), - - GROUPS_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP("groups,work_location,team,company,pay_group"), - - GROUPS_WORK_LOCATION_TEAM_PAY_GROUP("groups,work_location,team,pay_group"), - - HOME_LOCATION("home_location"), - - HOME_LOCATION_COMPANY("home_location,company"), - - HOME_LOCATION_COMPANY_PAY_GROUP("home_location,company,pay_group"), - - HOME_LOCATION_MANAGER("home_location,manager"), - - HOME_LOCATION_MANAGER_COMPANY("home_location,manager,company"), - - HOME_LOCATION_MANAGER_COMPANY_PAY_GROUP("home_location,manager,company,pay_group"), - - HOME_LOCATION_MANAGER_PAY_GROUP("home_location,manager,pay_group"), - - HOME_LOCATION_MANAGER_TEAM("home_location,manager,team"), - - HOME_LOCATION_MANAGER_TEAM_COMPANY("home_location,manager,team,company"), - - HOME_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP("home_location,manager,team,company,pay_group"), - - HOME_LOCATION_MANAGER_TEAM_PAY_GROUP("home_location,manager,team,pay_group"), - - HOME_LOCATION_PAY_GROUP("home_location,pay_group"), - - HOME_LOCATION_TEAM("home_location,team"), - - HOME_LOCATION_TEAM_COMPANY("home_location,team,company"), - - HOME_LOCATION_TEAM_COMPANY_PAY_GROUP("home_location,team,company,pay_group"), - - HOME_LOCATION_TEAM_PAY_GROUP("home_location,team,pay_group"), - - HOME_LOCATION_WORK_LOCATION("home_location,work_location"), - - HOME_LOCATION_WORK_LOCATION_COMPANY("home_location,work_location,company"), - - HOME_LOCATION_WORK_LOCATION_COMPANY_PAY_GROUP("home_location,work_location,company,pay_group"), - - HOME_LOCATION_WORK_LOCATION_MANAGER("home_location,work_location,manager"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY("home_location,work_location,manager,company"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP("home_location,work_location,manager,company,pay_group"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_PAY_GROUP("home_location,work_location,manager,pay_group"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM("home_location,work_location,manager,team"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY("home_location,work_location,manager,team,company"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "home_location,work_location,manager,team,company,pay_group"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP("home_location,work_location,manager,team,pay_group"), - - HOME_LOCATION_WORK_LOCATION_PAY_GROUP("home_location,work_location,pay_group"), - - HOME_LOCATION_WORK_LOCATION_TEAM("home_location,work_location,team"), - - HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY("home_location,work_location,team,company"), - - HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP("home_location,work_location,team,company,pay_group"), - - HOME_LOCATION_WORK_LOCATION_TEAM_PAY_GROUP("home_location,work_location,team,pay_group"), - - MANAGER("manager"), - - MANAGER_COMPANY("manager,company"), - - MANAGER_COMPANY_PAY_GROUP("manager,company,pay_group"), - - MANAGER_PAY_GROUP("manager,pay_group"), - - MANAGER_TEAM("manager,team"), - - MANAGER_TEAM_COMPANY("manager,team,company"), - - MANAGER_TEAM_COMPANY_PAY_GROUP("manager,team,company,pay_group"), - - MANAGER_TEAM_PAY_GROUP("manager,team,pay_group"), - - PAY_GROUP("pay_group"), - - TEAM("team"), - - TEAM_COMPANY("team,company"), - - TEAM_COMPANY_PAY_GROUP("team,company,pay_group"), - - TEAM_PAY_GROUP("team,pay_group"), - - WORK_LOCATION("work_location"), - - WORK_LOCATION_COMPANY("work_location,company"), - - WORK_LOCATION_COMPANY_PAY_GROUP("work_location,company,pay_group"), - - WORK_LOCATION_MANAGER("work_location,manager"), - - WORK_LOCATION_MANAGER_COMPANY("work_location,manager,company"), - - WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP("work_location,manager,company,pay_group"), - - WORK_LOCATION_MANAGER_PAY_GROUP("work_location,manager,pay_group"), - - WORK_LOCATION_MANAGER_TEAM("work_location,manager,team"), - - WORK_LOCATION_MANAGER_TEAM_COMPANY("work_location,manager,team,company"), - - WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP("work_location,manager,team,company,pay_group"), - - WORK_LOCATION_MANAGER_TEAM_PAY_GROUP("work_location,manager,team,pay_group"), - - WORK_LOCATION_PAY_GROUP("work_location,pay_group"), - - WORK_LOCATION_TEAM("work_location,team"), - - WORK_LOCATION_TEAM_COMPANY("work_location,team,company"), - - WORK_LOCATION_TEAM_COMPANY_PAY_GROUP("work_location,team,company,pay_group"), - - WORK_LOCATION_TEAM_PAY_GROUP("work_location,team,pay_group"); - - private final String value; - - EmployeesListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesListRequestExpandItem.java b/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesListRequestExpandItem.java new file mode 100644 index 000000000..bb271986e --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesListRequestExpandItem.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employees.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmployeesListRequestExpandItem { + COMPANY("company"), + + EMPLOYMENTS("employments"), + + GROUPS("groups"), + + HOME_LOCATION("home_location"), + + MANAGER("manager"), + + PAY_GROUP("pay_group"), + + TEAM("team"), + + WORK_LOCATION("work_location"); + + private final String value; + + EmployeesListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesRetrieveRequestExpand.java deleted file mode 100644 index 52c8bf29b..000000000 --- a/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesRetrieveRequestExpand.java +++ /dev/null @@ -1,560 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.employees.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum EmployeesRetrieveRequestExpand { - COMPANY("company"), - - COMPANY_PAY_GROUP("company,pay_group"), - - EMPLOYMENTS("employments"), - - EMPLOYMENTS_COMPANY("employments,company"), - - EMPLOYMENTS_COMPANY_PAY_GROUP("employments,company,pay_group"), - - EMPLOYMENTS_GROUPS("employments,groups"), - - EMPLOYMENTS_GROUPS_COMPANY("employments,groups,company"), - - EMPLOYMENTS_GROUPS_COMPANY_PAY_GROUP("employments,groups,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION("employments,groups,home_location"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_COMPANY("employments,groups,home_location,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_COMPANY_PAY_GROUP("employments,groups,home_location,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER("employments,groups,home_location,manager"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_COMPANY("employments,groups,home_location,manager,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_COMPANY_PAY_GROUP( - "employments,groups,home_location,manager,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_PAY_GROUP("employments,groups,home_location,manager,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_TEAM("employments,groups,home_location,manager,team"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_TEAM_COMPANY("employments,groups,home_location,manager,team,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,groups,home_location,manager,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_MANAGER_TEAM_PAY_GROUP("employments,groups,home_location,manager,team,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_PAY_GROUP("employments,groups,home_location,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_TEAM("employments,groups,home_location,team"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_TEAM_COMPANY("employments,groups,home_location,team,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_TEAM_COMPANY_PAY_GROUP("employments,groups,home_location,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_TEAM_PAY_GROUP("employments,groups,home_location,team,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION("employments,groups,home_location,work_location"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_COMPANY("employments,groups,home_location,work_location,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_COMPANY_PAY_GROUP( - "employments,groups,home_location,work_location,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER("employments,groups,home_location,work_location,manager"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY( - "employments,groups,home_location,work_location,manager,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP( - "employments,groups,home_location,work_location,manager,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_PAY_GROUP( - "employments,groups,home_location,work_location,manager,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM( - "employments,groups,home_location,work_location,manager,team"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY( - "employments,groups,home_location,work_location,manager,team,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,groups,home_location,work_location,manager,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP( - "employments,groups,home_location,work_location,manager,team,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_PAY_GROUP( - "employments,groups,home_location,work_location,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM("employments,groups,home_location,work_location,team"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY( - "employments,groups,home_location,work_location,team,company"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP( - "employments,groups,home_location,work_location,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_PAY_GROUP( - "employments,groups,home_location,work_location,team,pay_group"), - - EMPLOYMENTS_GROUPS_MANAGER("employments,groups,manager"), - - EMPLOYMENTS_GROUPS_MANAGER_COMPANY("employments,groups,manager,company"), - - EMPLOYMENTS_GROUPS_MANAGER_COMPANY_PAY_GROUP("employments,groups,manager,company,pay_group"), - - EMPLOYMENTS_GROUPS_MANAGER_PAY_GROUP("employments,groups,manager,pay_group"), - - EMPLOYMENTS_GROUPS_MANAGER_TEAM("employments,groups,manager,team"), - - EMPLOYMENTS_GROUPS_MANAGER_TEAM_COMPANY("employments,groups,manager,team,company"), - - EMPLOYMENTS_GROUPS_MANAGER_TEAM_COMPANY_PAY_GROUP("employments,groups,manager,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_MANAGER_TEAM_PAY_GROUP("employments,groups,manager,team,pay_group"), - - EMPLOYMENTS_GROUPS_PAY_GROUP("employments,groups,pay_group"), - - EMPLOYMENTS_GROUPS_TEAM("employments,groups,team"), - - EMPLOYMENTS_GROUPS_TEAM_COMPANY("employments,groups,team,company"), - - EMPLOYMENTS_GROUPS_TEAM_COMPANY_PAY_GROUP("employments,groups,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_TEAM_PAY_GROUP("employments,groups,team,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION("employments,groups,work_location"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_COMPANY("employments,groups,work_location,company"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_COMPANY_PAY_GROUP("employments,groups,work_location,company,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER("employments,groups,work_location,manager"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_COMPANY("employments,groups,work_location,manager,company"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP( - "employments,groups,work_location,manager,company,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_PAY_GROUP("employments,groups,work_location,manager,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_TEAM("employments,groups,work_location,manager,team"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_TEAM_COMPANY("employments,groups,work_location,manager,team,company"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,groups,work_location,manager,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP("employments,groups,work_location,manager,team,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_PAY_GROUP("employments,groups,work_location,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_TEAM("employments,groups,work_location,team"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_TEAM_COMPANY("employments,groups,work_location,team,company"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP("employments,groups,work_location,team,company,pay_group"), - - EMPLOYMENTS_GROUPS_WORK_LOCATION_TEAM_PAY_GROUP("employments,groups,work_location,team,pay_group"), - - EMPLOYMENTS_HOME_LOCATION("employments,home_location"), - - EMPLOYMENTS_HOME_LOCATION_COMPANY("employments,home_location,company"), - - EMPLOYMENTS_HOME_LOCATION_COMPANY_PAY_GROUP("employments,home_location,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER("employments,home_location,manager"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_COMPANY("employments,home_location,manager,company"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_COMPANY_PAY_GROUP("employments,home_location,manager,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_PAY_GROUP("employments,home_location,manager,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_TEAM("employments,home_location,manager,team"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_TEAM_COMPANY("employments,home_location,manager,team,company"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,home_location,manager,team,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_MANAGER_TEAM_PAY_GROUP("employments,home_location,manager,team,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_PAY_GROUP("employments,home_location,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_TEAM("employments,home_location,team"), - - EMPLOYMENTS_HOME_LOCATION_TEAM_COMPANY("employments,home_location,team,company"), - - EMPLOYMENTS_HOME_LOCATION_TEAM_COMPANY_PAY_GROUP("employments,home_location,team,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_TEAM_PAY_GROUP("employments,home_location,team,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION("employments,home_location,work_location"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_COMPANY("employments,home_location,work_location,company"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_COMPANY_PAY_GROUP( - "employments,home_location,work_location,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER("employments,home_location,work_location,manager"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY("employments,home_location,work_location,manager,company"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP( - "employments,home_location,work_location,manager,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_PAY_GROUP( - "employments,home_location,work_location,manager,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM("employments,home_location,work_location,manager,team"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY( - "employments,home_location,work_location,manager,team,company"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,home_location,work_location,manager,team,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP( - "employments,home_location,work_location,manager,team,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_PAY_GROUP("employments,home_location,work_location,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_TEAM("employments,home_location,work_location,team"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY("employments,home_location,work_location,team,company"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP( - "employments,home_location,work_location,team,company,pay_group"), - - EMPLOYMENTS_HOME_LOCATION_WORK_LOCATION_TEAM_PAY_GROUP("employments,home_location,work_location,team,pay_group"), - - EMPLOYMENTS_MANAGER("employments,manager"), - - EMPLOYMENTS_MANAGER_COMPANY("employments,manager,company"), - - EMPLOYMENTS_MANAGER_COMPANY_PAY_GROUP("employments,manager,company,pay_group"), - - EMPLOYMENTS_MANAGER_PAY_GROUP("employments,manager,pay_group"), - - EMPLOYMENTS_MANAGER_TEAM("employments,manager,team"), - - EMPLOYMENTS_MANAGER_TEAM_COMPANY("employments,manager,team,company"), - - EMPLOYMENTS_MANAGER_TEAM_COMPANY_PAY_GROUP("employments,manager,team,company,pay_group"), - - EMPLOYMENTS_MANAGER_TEAM_PAY_GROUP("employments,manager,team,pay_group"), - - EMPLOYMENTS_PAY_GROUP("employments,pay_group"), - - EMPLOYMENTS_TEAM("employments,team"), - - EMPLOYMENTS_TEAM_COMPANY("employments,team,company"), - - EMPLOYMENTS_TEAM_COMPANY_PAY_GROUP("employments,team,company,pay_group"), - - EMPLOYMENTS_TEAM_PAY_GROUP("employments,team,pay_group"), - - EMPLOYMENTS_WORK_LOCATION("employments,work_location"), - - EMPLOYMENTS_WORK_LOCATION_COMPANY("employments,work_location,company"), - - EMPLOYMENTS_WORK_LOCATION_COMPANY_PAY_GROUP("employments,work_location,company,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER("employments,work_location,manager"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_COMPANY("employments,work_location,manager,company"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP("employments,work_location,manager,company,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_PAY_GROUP("employments,work_location,manager,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_TEAM("employments,work_location,manager,team"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_TEAM_COMPANY("employments,work_location,manager,team,company"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "employments,work_location,manager,team,company,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP("employments,work_location,manager,team,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_PAY_GROUP("employments,work_location,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_TEAM("employments,work_location,team"), - - EMPLOYMENTS_WORK_LOCATION_TEAM_COMPANY("employments,work_location,team,company"), - - EMPLOYMENTS_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP("employments,work_location,team,company,pay_group"), - - EMPLOYMENTS_WORK_LOCATION_TEAM_PAY_GROUP("employments,work_location,team,pay_group"), - - GROUPS("groups"), - - GROUPS_COMPANY("groups,company"), - - GROUPS_COMPANY_PAY_GROUP("groups,company,pay_group"), - - GROUPS_HOME_LOCATION("groups,home_location"), - - GROUPS_HOME_LOCATION_COMPANY("groups,home_location,company"), - - GROUPS_HOME_LOCATION_COMPANY_PAY_GROUP("groups,home_location,company,pay_group"), - - GROUPS_HOME_LOCATION_MANAGER("groups,home_location,manager"), - - GROUPS_HOME_LOCATION_MANAGER_COMPANY("groups,home_location,manager,company"), - - GROUPS_HOME_LOCATION_MANAGER_COMPANY_PAY_GROUP("groups,home_location,manager,company,pay_group"), - - GROUPS_HOME_LOCATION_MANAGER_PAY_GROUP("groups,home_location,manager,pay_group"), - - GROUPS_HOME_LOCATION_MANAGER_TEAM("groups,home_location,manager,team"), - - GROUPS_HOME_LOCATION_MANAGER_TEAM_COMPANY("groups,home_location,manager,team,company"), - - GROUPS_HOME_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP("groups,home_location,manager,team,company,pay_group"), - - GROUPS_HOME_LOCATION_MANAGER_TEAM_PAY_GROUP("groups,home_location,manager,team,pay_group"), - - GROUPS_HOME_LOCATION_PAY_GROUP("groups,home_location,pay_group"), - - GROUPS_HOME_LOCATION_TEAM("groups,home_location,team"), - - GROUPS_HOME_LOCATION_TEAM_COMPANY("groups,home_location,team,company"), - - GROUPS_HOME_LOCATION_TEAM_COMPANY_PAY_GROUP("groups,home_location,team,company,pay_group"), - - GROUPS_HOME_LOCATION_TEAM_PAY_GROUP("groups,home_location,team,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION("groups,home_location,work_location"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_COMPANY("groups,home_location,work_location,company"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_COMPANY_PAY_GROUP("groups,home_location,work_location,company,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER("groups,home_location,work_location,manager"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY("groups,home_location,work_location,manager,company"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP( - "groups,home_location,work_location,manager,company,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_PAY_GROUP("groups,home_location,work_location,manager,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM("groups,home_location,work_location,manager,team"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY("groups,home_location,work_location,manager,team,company"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "groups,home_location,work_location,manager,team,company,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP( - "groups,home_location,work_location,manager,team,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_PAY_GROUP("groups,home_location,work_location,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM("groups,home_location,work_location,team"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY("groups,home_location,work_location,team,company"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP( - "groups,home_location,work_location,team,company,pay_group"), - - GROUPS_HOME_LOCATION_WORK_LOCATION_TEAM_PAY_GROUP("groups,home_location,work_location,team,pay_group"), - - GROUPS_MANAGER("groups,manager"), - - GROUPS_MANAGER_COMPANY("groups,manager,company"), - - GROUPS_MANAGER_COMPANY_PAY_GROUP("groups,manager,company,pay_group"), - - GROUPS_MANAGER_PAY_GROUP("groups,manager,pay_group"), - - GROUPS_MANAGER_TEAM("groups,manager,team"), - - GROUPS_MANAGER_TEAM_COMPANY("groups,manager,team,company"), - - GROUPS_MANAGER_TEAM_COMPANY_PAY_GROUP("groups,manager,team,company,pay_group"), - - GROUPS_MANAGER_TEAM_PAY_GROUP("groups,manager,team,pay_group"), - - GROUPS_PAY_GROUP("groups,pay_group"), - - GROUPS_TEAM("groups,team"), - - GROUPS_TEAM_COMPANY("groups,team,company"), - - GROUPS_TEAM_COMPANY_PAY_GROUP("groups,team,company,pay_group"), - - GROUPS_TEAM_PAY_GROUP("groups,team,pay_group"), - - GROUPS_WORK_LOCATION("groups,work_location"), - - GROUPS_WORK_LOCATION_COMPANY("groups,work_location,company"), - - GROUPS_WORK_LOCATION_COMPANY_PAY_GROUP("groups,work_location,company,pay_group"), - - GROUPS_WORK_LOCATION_MANAGER("groups,work_location,manager"), - - GROUPS_WORK_LOCATION_MANAGER_COMPANY("groups,work_location,manager,company"), - - GROUPS_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP("groups,work_location,manager,company,pay_group"), - - GROUPS_WORK_LOCATION_MANAGER_PAY_GROUP("groups,work_location,manager,pay_group"), - - GROUPS_WORK_LOCATION_MANAGER_TEAM("groups,work_location,manager,team"), - - GROUPS_WORK_LOCATION_MANAGER_TEAM_COMPANY("groups,work_location,manager,team,company"), - - GROUPS_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP("groups,work_location,manager,team,company,pay_group"), - - GROUPS_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP("groups,work_location,manager,team,pay_group"), - - GROUPS_WORK_LOCATION_PAY_GROUP("groups,work_location,pay_group"), - - GROUPS_WORK_LOCATION_TEAM("groups,work_location,team"), - - GROUPS_WORK_LOCATION_TEAM_COMPANY("groups,work_location,team,company"), - - GROUPS_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP("groups,work_location,team,company,pay_group"), - - GROUPS_WORK_LOCATION_TEAM_PAY_GROUP("groups,work_location,team,pay_group"), - - HOME_LOCATION("home_location"), - - HOME_LOCATION_COMPANY("home_location,company"), - - HOME_LOCATION_COMPANY_PAY_GROUP("home_location,company,pay_group"), - - HOME_LOCATION_MANAGER("home_location,manager"), - - HOME_LOCATION_MANAGER_COMPANY("home_location,manager,company"), - - HOME_LOCATION_MANAGER_COMPANY_PAY_GROUP("home_location,manager,company,pay_group"), - - HOME_LOCATION_MANAGER_PAY_GROUP("home_location,manager,pay_group"), - - HOME_LOCATION_MANAGER_TEAM("home_location,manager,team"), - - HOME_LOCATION_MANAGER_TEAM_COMPANY("home_location,manager,team,company"), - - HOME_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP("home_location,manager,team,company,pay_group"), - - HOME_LOCATION_MANAGER_TEAM_PAY_GROUP("home_location,manager,team,pay_group"), - - HOME_LOCATION_PAY_GROUP("home_location,pay_group"), - - HOME_LOCATION_TEAM("home_location,team"), - - HOME_LOCATION_TEAM_COMPANY("home_location,team,company"), - - HOME_LOCATION_TEAM_COMPANY_PAY_GROUP("home_location,team,company,pay_group"), - - HOME_LOCATION_TEAM_PAY_GROUP("home_location,team,pay_group"), - - HOME_LOCATION_WORK_LOCATION("home_location,work_location"), - - HOME_LOCATION_WORK_LOCATION_COMPANY("home_location,work_location,company"), - - HOME_LOCATION_WORK_LOCATION_COMPANY_PAY_GROUP("home_location,work_location,company,pay_group"), - - HOME_LOCATION_WORK_LOCATION_MANAGER("home_location,work_location,manager"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY("home_location,work_location,manager,company"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP("home_location,work_location,manager,company,pay_group"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_PAY_GROUP("home_location,work_location,manager,pay_group"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM("home_location,work_location,manager,team"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY("home_location,work_location,manager,team,company"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP( - "home_location,work_location,manager,team,company,pay_group"), - - HOME_LOCATION_WORK_LOCATION_MANAGER_TEAM_PAY_GROUP("home_location,work_location,manager,team,pay_group"), - - HOME_LOCATION_WORK_LOCATION_PAY_GROUP("home_location,work_location,pay_group"), - - HOME_LOCATION_WORK_LOCATION_TEAM("home_location,work_location,team"), - - HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY("home_location,work_location,team,company"), - - HOME_LOCATION_WORK_LOCATION_TEAM_COMPANY_PAY_GROUP("home_location,work_location,team,company,pay_group"), - - HOME_LOCATION_WORK_LOCATION_TEAM_PAY_GROUP("home_location,work_location,team,pay_group"), - - MANAGER("manager"), - - MANAGER_COMPANY("manager,company"), - - MANAGER_COMPANY_PAY_GROUP("manager,company,pay_group"), - - MANAGER_PAY_GROUP("manager,pay_group"), - - MANAGER_TEAM("manager,team"), - - MANAGER_TEAM_COMPANY("manager,team,company"), - - MANAGER_TEAM_COMPANY_PAY_GROUP("manager,team,company,pay_group"), - - MANAGER_TEAM_PAY_GROUP("manager,team,pay_group"), - - PAY_GROUP("pay_group"), - - TEAM("team"), - - TEAM_COMPANY("team,company"), - - TEAM_COMPANY_PAY_GROUP("team,company,pay_group"), - - TEAM_PAY_GROUP("team,pay_group"), - - WORK_LOCATION("work_location"), - - WORK_LOCATION_COMPANY("work_location,company"), - - WORK_LOCATION_COMPANY_PAY_GROUP("work_location,company,pay_group"), - - WORK_LOCATION_MANAGER("work_location,manager"), - - WORK_LOCATION_MANAGER_COMPANY("work_location,manager,company"), - - WORK_LOCATION_MANAGER_COMPANY_PAY_GROUP("work_location,manager,company,pay_group"), - - WORK_LOCATION_MANAGER_PAY_GROUP("work_location,manager,pay_group"), - - WORK_LOCATION_MANAGER_TEAM("work_location,manager,team"), - - WORK_LOCATION_MANAGER_TEAM_COMPANY("work_location,manager,team,company"), - - WORK_LOCATION_MANAGER_TEAM_COMPANY_PAY_GROUP("work_location,manager,team,company,pay_group"), - - WORK_LOCATION_MANAGER_TEAM_PAY_GROUP("work_location,manager,team,pay_group"), - - WORK_LOCATION_PAY_GROUP("work_location,pay_group"), - - WORK_LOCATION_TEAM("work_location,team"), - - WORK_LOCATION_TEAM_COMPANY("work_location,team,company"), - - WORK_LOCATION_TEAM_COMPANY_PAY_GROUP("work_location,team,company,pay_group"), - - WORK_LOCATION_TEAM_PAY_GROUP("work_location,team,pay_group"); - - private final String value; - - EmployeesRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesRetrieveRequestExpandItem.java new file mode 100644 index 000000000..a3a40a159 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employees/types/EmployeesRetrieveRequestExpandItem.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employees.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmployeesRetrieveRequestExpandItem { + COMPANY("company"), + + EMPLOYMENTS("employments"), + + GROUPS("groups"), + + HOME_LOCATION("home_location"), + + MANAGER("manager"), + + PAY_GROUP("pay_group"), + + TEAM("team"), + + WORK_LOCATION("work_location"); + + private final String value; + + EmployeesRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employees/types/IgnoreCommonModelRequestReason.java b/src/main/java/com/merge/api/resources/hris/employees/types/IgnoreCommonModelRequestReason.java deleted file mode 100644 index bdf41e70d..000000000 --- a/src/main/java/com/merge/api/resources/hris/employees/types/IgnoreCommonModelRequestReason.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.employees.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.hris.types.ReasonEnum; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = IgnoreCommonModelRequestReason.Deserializer.class) -public final class IgnoreCommonModelRequestReason { - private final Object value; - - private final int type; - - private IgnoreCommonModelRequestReason(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ReasonEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IgnoreCommonModelRequestReason && equalTo((IgnoreCommonModelRequestReason) other); - } - - private boolean equalTo(IgnoreCommonModelRequestReason other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static IgnoreCommonModelRequestReason of(ReasonEnum value) { - return new IgnoreCommonModelRequestReason(value, 0); - } - - public static IgnoreCommonModelRequestReason of(String value) { - return new IgnoreCommonModelRequestReason(value, 1); - } - - public interface Visitor { - T visit(ReasonEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(IgnoreCommonModelRequestReason.class); - } - - @java.lang.Override - public IgnoreCommonModelRequestReason deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ReasonEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/employerbenefits/AsyncEmployerBenefitsClient.java b/src/main/java/com/merge/api/resources/hris/employerbenefits/AsyncEmployerBenefitsClient.java new file mode 100644 index 000000000..ebcebded9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employerbenefits/AsyncEmployerBenefitsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employerbenefits; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employerbenefits.requests.EmployerBenefitsListRequest; +import com.merge.api.resources.hris.employerbenefits.requests.EmployerBenefitsRetrieveRequest; +import com.merge.api.resources.hris.types.EmployerBenefit; +import com.merge.api.resources.hris.types.PaginatedEmployerBenefitList; +import java.util.concurrent.CompletableFuture; + +public class AsyncEmployerBenefitsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawEmployerBenefitsClient rawClient; + + public AsyncEmployerBenefitsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawEmployerBenefitsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawEmployerBenefitsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of EmployerBenefit objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of EmployerBenefit objects. + */ + public CompletableFuture list(EmployerBenefitsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of EmployerBenefit objects. + */ + public CompletableFuture list( + EmployerBenefitsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an EmployerBenefit object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an EmployerBenefit object with the given id. + */ + public CompletableFuture retrieve(String id, EmployerBenefitsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an EmployerBenefit object with the given id. + */ + public CompletableFuture retrieve( + String id, EmployerBenefitsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employerbenefits/AsyncRawEmployerBenefitsClient.java b/src/main/java/com/merge/api/resources/hris/employerbenefits/AsyncRawEmployerBenefitsClient.java new file mode 100644 index 000000000..52ff25d54 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employerbenefits/AsyncRawEmployerBenefitsClient.java @@ -0,0 +1,233 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employerbenefits; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employerbenefits.requests.EmployerBenefitsListRequest; +import com.merge.api.resources.hris.employerbenefits.requests.EmployerBenefitsRetrieveRequest; +import com.merge.api.resources.hris.types.EmployerBenefit; +import com.merge.api.resources.hris.types.PaginatedEmployerBenefitList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawEmployerBenefitsClient { + protected final ClientOptions clientOptions; + + public AsyncRawEmployerBenefitsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of EmployerBenefit objects. + */ + public CompletableFuture> list() { + return list(EmployerBenefitsListRequest.builder().build()); + } + + /** + * Returns a list of EmployerBenefit objects. + */ + public CompletableFuture> list( + EmployerBenefitsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of EmployerBenefit objects. + */ + public CompletableFuture> list( + EmployerBenefitsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employer-benefits"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedEmployerBenefitList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an EmployerBenefit object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, EmployerBenefitsRetrieveRequest.builder().build()); + } + + /** + * Returns an EmployerBenefit object with the given id. + */ + public CompletableFuture> retrieve( + String id, EmployerBenefitsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an EmployerBenefit object with the given id. + */ + public CompletableFuture> retrieve( + String id, EmployerBenefitsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employer-benefits") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EmployerBenefit.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employerbenefits/EmployerBenefitsClient.java b/src/main/java/com/merge/api/resources/hris/employerbenefits/EmployerBenefitsClient.java index c59c243d3..157ef8b04 100644 --- a/src/main/java/com/merge/api/resources/hris/employerbenefits/EmployerBenefitsClient.java +++ b/src/main/java/com/merge/api/resources/hris/employerbenefits/EmployerBenefitsClient.java @@ -3,164 +3,69 @@ */ package com.merge.api.resources.hris.employerbenefits; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.employerbenefits.requests.EmployerBenefitsListRequest; import com.merge.api.resources.hris.employerbenefits.requests.EmployerBenefitsRetrieveRequest; import com.merge.api.resources.hris.types.EmployerBenefit; import com.merge.api.resources.hris.types.PaginatedEmployerBenefitList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class EmployerBenefitsClient { protected final ClientOptions clientOptions; + private final RawEmployerBenefitsClient rawClient; + public EmployerBenefitsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawEmployerBenefitsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawEmployerBenefitsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of EmployerBenefit objects. */ public PaginatedEmployerBenefitList list() { - return list(EmployerBenefitsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of EmployerBenefit objects. */ public PaginatedEmployerBenefitList list(EmployerBenefitsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of EmployerBenefit objects. */ public PaginatedEmployerBenefitList list(EmployerBenefitsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employer-benefits"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEmployerBenefitList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an EmployerBenefit object with the given id. */ public EmployerBenefit retrieve(String id) { - return retrieve(id, EmployerBenefitsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an EmployerBenefit object with the given id. */ public EmployerBenefit retrieve(String id, EmployerBenefitsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an EmployerBenefit object with the given id. */ public EmployerBenefit retrieve(String id, EmployerBenefitsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employer-benefits") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EmployerBenefit.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/employerbenefits/RawEmployerBenefitsClient.java b/src/main/java/com/merge/api/resources/hris/employerbenefits/RawEmployerBenefitsClient.java new file mode 100644 index 000000000..456b99636 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employerbenefits/RawEmployerBenefitsClient.java @@ -0,0 +1,199 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employerbenefits; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employerbenefits.requests.EmployerBenefitsListRequest; +import com.merge.api.resources.hris.employerbenefits.requests.EmployerBenefitsRetrieveRequest; +import com.merge.api.resources.hris.types.EmployerBenefit; +import com.merge.api.resources.hris.types.PaginatedEmployerBenefitList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawEmployerBenefitsClient { + protected final ClientOptions clientOptions; + + public RawEmployerBenefitsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of EmployerBenefit objects. + */ + public MergeApiHttpResponse list() { + return list(EmployerBenefitsListRequest.builder().build()); + } + + /** + * Returns a list of EmployerBenefit objects. + */ + public MergeApiHttpResponse list(EmployerBenefitsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of EmployerBenefit objects. + */ + public MergeApiHttpResponse list( + EmployerBenefitsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employer-benefits"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEmployerBenefitList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an EmployerBenefit object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, EmployerBenefitsRetrieveRequest.builder().build()); + } + + /** + * Returns an EmployerBenefit object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, EmployerBenefitsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an EmployerBenefit object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, EmployerBenefitsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employer-benefits") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), EmployerBenefit.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employerbenefits/requests/EmployerBenefitsRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/employerbenefits/requests/EmployerBenefitsRetrieveRequest.java index c830bbfe7..be3446cfb 100644 --- a/src/main/java/com/merge/api/resources/hris/employerbenefits/requests/EmployerBenefitsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/employerbenefits/requests/EmployerBenefitsRetrieveRequest.java @@ -22,11 +22,16 @@ public final class EmployerBenefitsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private EmployerBenefitsRetrieveRequest( - Optional includeRemoteData, Map additionalProperties) { + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -38,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -50,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(EmployerBenefitsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -71,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -78,6 +93,7 @@ private Builder() {} public Builder from(EmployerBenefitsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -92,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public EmployerBenefitsRetrieveRequest build() { - return new EmployerBenefitsRetrieveRequest(includeRemoteData, additionalProperties); + return new EmployerBenefitsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/employments/AsyncEmploymentsClient.java b/src/main/java/com/merge/api/resources/hris/employments/AsyncEmploymentsClient.java new file mode 100644 index 000000000..6a3582bfb --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employments/AsyncEmploymentsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employments; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employments.requests.EmploymentsListRequest; +import com.merge.api.resources.hris.employments.requests.EmploymentsRetrieveRequest; +import com.merge.api.resources.hris.types.Employment; +import com.merge.api.resources.hris.types.PaginatedEmploymentList; +import java.util.concurrent.CompletableFuture; + +public class AsyncEmploymentsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawEmploymentsClient rawClient; + + public AsyncEmploymentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawEmploymentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawEmploymentsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Employment objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Employment objects. + */ + public CompletableFuture list(EmploymentsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Employment objects. + */ + public CompletableFuture list( + EmploymentsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Employment object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Employment object with the given id. + */ + public CompletableFuture retrieve(String id, EmploymentsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Employment object with the given id. + */ + public CompletableFuture retrieve( + String id, EmploymentsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employments/AsyncRawEmploymentsClient.java b/src/main/java/com/merge/api/resources/hris/employments/AsyncRawEmploymentsClient.java new file mode 100644 index 000000000..e198acff3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employments/AsyncRawEmploymentsClient.java @@ -0,0 +1,269 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employments.requests.EmploymentsListRequest; +import com.merge.api.resources.hris.employments.requests.EmploymentsRetrieveRequest; +import com.merge.api.resources.hris.types.Employment; +import com.merge.api.resources.hris.types.PaginatedEmploymentList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawEmploymentsClient { + protected final ClientOptions clientOptions; + + public AsyncRawEmploymentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Employment objects. + */ + public CompletableFuture> list() { + return list(EmploymentsListRequest.builder().build()); + } + + /** + * Returns a list of Employment objects. + */ + public CompletableFuture> list(EmploymentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Employment objects. + */ + public CompletableFuture> list( + EmploymentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employments"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOrderBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order_by", request.getOrderBy().get().toString(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedEmploymentList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Employment object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, EmploymentsRetrieveRequest.builder().build()); + } + + /** + * Returns an Employment object with the given id. + */ + public CompletableFuture> retrieve(String id, EmploymentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Employment object with the given id. + */ + public CompletableFuture> retrieve( + String id, EmploymentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Employment.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employments/EmploymentsClient.java b/src/main/java/com/merge/api/resources/hris/employments/EmploymentsClient.java index ba2704eb0..4e1cc138d 100644 --- a/src/main/java/com/merge/api/resources/hris/employments/EmploymentsClient.java +++ b/src/main/java/com/merge/api/resources/hris/employments/EmploymentsClient.java @@ -3,192 +3,69 @@ */ package com.merge.api.resources.hris.employments; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.employments.requests.EmploymentsListRequest; import com.merge.api.resources.hris.employments.requests.EmploymentsRetrieveRequest; import com.merge.api.resources.hris.types.Employment; import com.merge.api.resources.hris.types.PaginatedEmploymentList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class EmploymentsClient { protected final ClientOptions clientOptions; + private final RawEmploymentsClient rawClient; + public EmploymentsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawEmploymentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawEmploymentsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Employment objects. */ public PaginatedEmploymentList list() { - return list(EmploymentsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Employment objects. */ public PaginatedEmploymentList list(EmploymentsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Employment objects. */ public PaginatedEmploymentList list(EmploymentsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employments"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmployeeId().isPresent()) { - httpUrl.addQueryParameter("employee_id", request.getEmployeeId().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getOrderBy().isPresent()) { - httpUrl.addQueryParameter("order_by", request.getOrderBy().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEmploymentList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an Employment object with the given id. */ public Employment retrieve(String id) { - return retrieve(id, EmploymentsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Employment object with the given id. */ public Employment retrieve(String id, EmploymentsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Employment object with the given id. */ public Employment retrieve(String id, EmploymentsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/employments") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Employment.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/employments/RawEmploymentsClient.java b/src/main/java/com/merge/api/resources/hris/employments/RawEmploymentsClient.java new file mode 100644 index 000000000..edafd0e14 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employments/RawEmploymentsClient.java @@ -0,0 +1,237 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.employments.requests.EmploymentsListRequest; +import com.merge.api.resources.hris.employments.requests.EmploymentsRetrieveRequest; +import com.merge.api.resources.hris.types.Employment; +import com.merge.api.resources.hris.types.PaginatedEmploymentList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawEmploymentsClient { + protected final ClientOptions clientOptions; + + public RawEmploymentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Employment objects. + */ + public MergeApiHttpResponse list() { + return list(EmploymentsListRequest.builder().build()); + } + + /** + * Returns a list of Employment objects. + */ + public MergeApiHttpResponse list(EmploymentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Employment objects. + */ + public MergeApiHttpResponse list( + EmploymentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employments"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOrderBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order_by", request.getOrderBy().get().toString(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedEmploymentList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Employment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, EmploymentsRetrieveRequest.builder().build()); + } + + /** + * Returns an Employment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, EmploymentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Employment object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, EmploymentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/employments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Employment.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employments/requests/EmploymentsListRequest.java b/src/main/java/com/merge/api/resources/hris/employments/requests/EmploymentsListRequest.java index 96a6f19df..c066a6fde 100644 --- a/src/main/java/com/merge/api/resources/hris/employments/requests/EmploymentsListRequest.java +++ b/src/main/java/com/merge/api/resources/hris/employments/requests/EmploymentsListRequest.java @@ -12,12 +12,14 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.hris.employments.types.EmploymentsListRequestExpand; +import com.merge.api.resources.hris.employments.types.EmploymentsListRequestExpandItem; import com.merge.api.resources.hris.employments.types.EmploymentsListRequestOrderBy; import com.merge.api.resources.hris.employments.types.EmploymentsListRequestRemoteFields; import com.merge.api.resources.hris.employments.types.EmploymentsListRequestShowEnumOrigins; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -25,6 +27,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EmploymentsListRequest.Builder.class) public final class EmploymentsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; @@ -33,8 +37,6 @@ public final class EmploymentsListRequest { private final Optional employeeId; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -58,11 +60,11 @@ public final class EmploymentsListRequest { private final Map additionalProperties; private EmploymentsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, Optional employeeId, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -74,11 +76,11 @@ private EmploymentsListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.employeeId = employeeId; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -92,6 +94,14 @@ private EmploymentsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -124,14 +134,6 @@ public Optional getEmployeeId() { return employeeId; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -224,11 +226,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(EmploymentsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && employeeId.equals(other.employeeId) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -244,11 +246,11 @@ private boolean equalTo(EmploymentsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, this.employeeId, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -272,6 +274,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); @@ -280,8 +284,6 @@ public static final class Builder { private Optional employeeId = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -308,11 +310,11 @@ public static final class Builder { private Builder() {} public Builder from(EmploymentsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); employeeId(other.getEmployeeId()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -326,6 +328,22 @@ public Builder from(EmploymentsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(EmploymentsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -370,17 +388,6 @@ public Builder employeeId(String employeeId) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(EmploymentsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -493,11 +500,11 @@ public Builder showEnumOrigins(EmploymentsListRequestShowEnumOrigins showEnumOri public EmploymentsListRequest build() { return new EmploymentsListRequest( + expand, createdAfter, createdBefore, cursor, employeeId, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/hris/employments/requests/EmploymentsRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/employments/requests/EmploymentsRetrieveRequest.java index 7e139618c..2ee943715 100644 --- a/src/main/java/com/merge/api/resources/hris/employments/requests/EmploymentsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/employments/requests/EmploymentsRetrieveRequest.java @@ -12,10 +12,12 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.hris.employments.types.EmploymentsRetrieveRequestExpand; +import com.merge.api.resources.hris.employments.types.EmploymentsRetrieveRequestExpandItem; import com.merge.api.resources.hris.employments.types.EmploymentsRetrieveRequestRemoteFields; import com.merge.api.resources.hris.employments.types.EmploymentsRetrieveRequestShowEnumOrigins; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,10 +25,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = EmploymentsRetrieveRequest.Builder.class) public final class EmploymentsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -34,13 +38,15 @@ public final class EmploymentsRetrieveRequest { private final Map additionalProperties; private EmploymentsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -50,7 +56,7 @@ private EmploymentsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -62,6 +68,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -92,13 +106,15 @@ public Map getAdditionalProperties() { private boolean equalTo(EmploymentsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -112,10 +128,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -128,22 +146,28 @@ private Builder() {} public Builder from(EmploymentsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(EmploymentsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(EmploymentsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -155,6 +179,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -179,7 +214,7 @@ public Builder showEnumOrigins(EmploymentsRetrieveRequestShowEnumOrigins showEnu public EmploymentsRetrieveRequest build() { return new EmploymentsRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsListRequestExpand.java b/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsListRequestExpand.java deleted file mode 100644 index 6b7949280..000000000 --- a/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.employments.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum EmploymentsListRequestExpand { - EMPLOYEE("employee"), - - EMPLOYEE_PAY_GROUP("employee,pay_group"), - - PAY_GROUP("pay_group"); - - private final String value; - - EmploymentsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsListRequestExpandItem.java new file mode 100644 index 000000000..e2faa03ee --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employments.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmploymentsListRequestExpandItem { + EMPLOYEE("employee"), + + PAY_GROUP("pay_group"); + + private final String value; + + EmploymentsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsRetrieveRequestExpand.java deleted file mode 100644 index 5d269f760..000000000 --- a/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsRetrieveRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.employments.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum EmploymentsRetrieveRequestExpand { - EMPLOYEE("employee"), - - EMPLOYEE_PAY_GROUP("employee,pay_group"), - - PAY_GROUP("pay_group"); - - private final String value; - - EmploymentsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..d23880fb2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/employments/types/EmploymentsRetrieveRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.employments.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum EmploymentsRetrieveRequestExpandItem { + EMPLOYEE("employee"), + + PAY_GROUP("pay_group"); + + private final String value; + + EmploymentsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/fieldmapping/AsyncFieldMappingClient.java b/src/main/java/com/merge/api/resources/hris/fieldmapping/AsyncFieldMappingClient.java new file mode 100644 index 000000000..e18fdcd49 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/fieldmapping/AsyncFieldMappingClient.java @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.fieldmapping; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.hris.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.hris.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.hris.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.hris.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.hris.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.hris.types.FieldMappingInstanceResponse; +import com.merge.api.resources.hris.types.RemoteFieldApiResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncFieldMappingClient { + protected final ClientOptions clientOptions; + + private final AsyncRawFieldMappingClient rawClient; + + public AsyncFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawFieldMappingClient withRawResponse() { + return this.rawClient; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve() { + return this.rawClient.fieldMappingsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return this.rawClient.fieldMappingsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate(CreateFieldMappingRequest request) { + return this.rawClient.fieldMappingsCreate(request).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsCreate(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy(String fieldMappingId) { + return this.rawClient.fieldMappingsDestroy(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate(String fieldMappingId) { + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve() { + return this.rawClient.remoteFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return this.rawClient.remoteFieldsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve() { + return this.rawClient.targetFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve(RequestOptions requestOptions) { + return this.rawClient.targetFieldsRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/fieldmapping/AsyncRawFieldMappingClient.java b/src/main/java/com/merge/api/resources/hris/fieldmapping/AsyncRawFieldMappingClient.java new file mode 100644 index 000000000..2e5808f31 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/fieldmapping/AsyncRawFieldMappingClient.java @@ -0,0 +1,471 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.hris.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.hris.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.hris.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.hris.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.hris.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.hris.types.FieldMappingInstanceResponse; +import com.merge.api.resources.hris.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawFieldMappingClient { + protected final ClientOptions clientOptions; + + public AsyncRawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), RemoteFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/fieldmapping/FieldMappingClient.java b/src/main/java/com/merge/api/resources/hris/fieldmapping/FieldMappingClient.java index 305241370..2f6633e31 100644 --- a/src/main/java/com/merge/api/resources/hris/fieldmapping/FieldMappingClient.java +++ b/src/main/java/com/merge/api/resources/hris/fieldmapping/FieldMappingClient.java @@ -3,12 +3,7 @@ */ package com.merge.api.resources.hris.fieldmapping; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.fieldmapping.requests.CreateFieldMappingRequest; import com.merge.api.resources.hris.fieldmapping.requests.FieldMappingsRetrieveRequest; @@ -18,36 +13,36 @@ import com.merge.api.resources.hris.types.FieldMappingApiInstanceResponse; import com.merge.api.resources.hris.types.FieldMappingInstanceResponse; import com.merge.api.resources.hris.types.RemoteFieldApiResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class FieldMappingClient { protected final ClientOptions clientOptions; + private final RawFieldMappingClient rawClient; + public FieldMappingClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawFieldMappingClient withRawResponse() { + return this.rawClient; } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve() { - return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + return this.rawClient.fieldMappingsRetrieve().body(); } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrieveRequest request) { - return fieldMappingsRetrieve(request, null); + return this.rawClient.fieldMappingsRetrieve(request).body(); } /** @@ -55,46 +50,14 @@ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrie */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve( FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), FieldMappingApiInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).body(); } /** * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingRequest request) { - return fieldMappingsCreate(request, null); + return this.rawClient.fieldMappingsCreate(request).body(); } /** @@ -102,102 +65,30 @@ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingReques */ public FieldMappingInstanceResponse fieldMappingsCreate( CreateFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("target_field_name", request.getTargetFieldName()); - properties.put("target_field_description", request.getTargetFieldDescription()); - properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); - properties.put("remote_method", request.getRemoteMethod()); - properties.put("remote_url_path", request.getRemoteUrlPath()); - properties.put("common_model_name", request.getCommonModelName()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsCreate(request, requestOptions).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId) { - return fieldMappingsDestroy(fieldMappingId, null); + return this.rawClient.fieldMappingsDestroy(fieldMappingId).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .body(); } /** * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappingId) { - return fieldMappingsPartialUpdate( - fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).body(); } /** @@ -205,7 +96,9 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappi */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request) { - return fieldMappingsPartialUpdate(fieldMappingId, request, null); + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .body(); } /** @@ -213,56 +106,23 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve() { - return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + return this.rawClient.remoteFieldsRetrieve().body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { - return remoteFieldsRetrieve(request, null); + return this.rawClient.remoteFieldsRetrieve(request).body(); } /** @@ -270,80 +130,20 @@ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest r */ public RemoteFieldApiResponse remoteFieldsRetrieve( RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/remote-fields"); - if (request.getCommonModels().isPresent()) { - httpUrl.addQueryParameter("common_models", request.getCommonModels().get()); - } - if (request.getIncludeExampleValues().isPresent()) { - httpUrl.addQueryParameter( - "include_example_values", request.getIncludeExampleValues().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve() { - return targetFieldsRetrieve(null); + return this.rawClient.targetFieldsRetrieve().body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/target-fields") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalTargetFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.targetFieldsRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/fieldmapping/RawFieldMappingClient.java b/src/main/java/com/merge/api/resources/hris/fieldmapping/RawFieldMappingClient.java new file mode 100644 index 000000000..47c2c58bd --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/fieldmapping/RawFieldMappingClient.java @@ -0,0 +1,380 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.hris.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.hris.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.hris.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.hris.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.hris.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.hris.types.FieldMappingInstanceResponse; +import com.merge.api.resources.hris.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawFieldMappingClient { + protected final ClientOptions clientOptions; + + public RawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate(CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy(String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate(String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/forceresync/AsyncForceResyncClient.java b/src/main/java/com/merge/api/resources/hris/forceresync/AsyncForceResyncClient.java new file mode 100644 index 000000000..877a8c808 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/forceresync/AsyncForceResyncClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.forceresync; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.SyncStatus; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncForceResyncClient { + protected final ClientOptions clientOptions; + + private final AsyncRawForceResyncClient rawClient; + + public AsyncForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawForceResyncClient withRawResponse() { + return this.rawClient; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate() { + return this.rawClient.syncStatusResyncCreate().thenApply(response -> response.body()); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate(RequestOptions requestOptions) { + return this.rawClient.syncStatusResyncCreate(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/forceresync/AsyncRawForceResyncClient.java b/src/main/java/com/merge/api/resources/hris/forceresync/AsyncRawForceResyncClient.java new file mode 100644 index 000000000..7d5f702ae --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/forceresync/AsyncRawForceResyncClient.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawForceResyncClient { + protected final ClientOptions clientOptions; + + public AsyncRawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/forceresync/ForceResyncClient.java b/src/main/java/com/merge/api/resources/hris/forceresync/ForceResyncClient.java index f2573fe6d..0377a4526 100644 --- a/src/main/java/com/merge/api/resources/hris/forceresync/ForceResyncClient.java +++ b/src/main/java/com/merge/api/resources/hris/forceresync/ForceResyncClient.java @@ -3,69 +3,39 @@ */ package com.merge.api.resources.hris.forceresync; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.types.SyncStatus; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ForceResyncClient { protected final ClientOptions clientOptions; + private final RawForceResyncClient rawClient; + public ForceResyncClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawForceResyncClient withRawResponse() { + return this.rawClient; } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate() { - return syncStatusResyncCreate(null); + return this.rawClient.syncStatusResyncCreate().body(); } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/sync-status/resync") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.syncStatusResyncCreate(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/forceresync/RawForceResyncClient.java b/src/main/java/com/merge/api/resources/hris/forceresync/RawForceResyncClient.java new file mode 100644 index 000000000..5b3d5277f --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/forceresync/RawForceResyncClient.java @@ -0,0 +1,75 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawForceResyncClient { + protected final ClientOptions clientOptions; + + public RawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/generatekey/AsyncGenerateKeyClient.java b/src/main/java/com/merge/api/resources/hris/generatekey/AsyncGenerateKeyClient.java new file mode 100644 index 000000000..f78224461 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/generatekey/AsyncGenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.generatekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.hris.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncGenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawGenerateKeyClient rawClient; + + public AsyncGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawGenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/generatekey/AsyncRawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/hris/generatekey/AsyncRawGenerateKeyClient.java new file mode 100644 index 000000000..c7ed9e576 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/generatekey/AsyncRawGenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.hris.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public CompletableFuture> create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public CompletableFuture> create( + GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/generatekey/GenerateKeyClient.java b/src/main/java/com/merge/api/resources/hris/generatekey/GenerateKeyClient.java index 675af7e16..4b09dca08 100644 --- a/src/main/java/com/merge/api/resources/hris/generatekey/GenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/hris/generatekey/GenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.hris.generatekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.generatekey.requests.GenerateRemoteKeyRequest; import com.merge.api.resources.hris.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class GenerateKeyClient { protected final ClientOptions clientOptions; + private final RawGenerateKeyClient rawClient; + public GenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawGenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/generate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/generatekey/RawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/hris/generatekey/RawGenerateKeyClient.java new file mode 100644 index 000000000..807d0fe1d --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/generatekey/RawGenerateKeyClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.hris.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/groups/AsyncGroupsClient.java b/src/main/java/com/merge/api/resources/hris/groups/AsyncGroupsClient.java new file mode 100644 index 000000000..8ee40c4e6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/groups/AsyncGroupsClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.groups; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.groups.requests.GroupsListRequest; +import com.merge.api.resources.hris.groups.requests.GroupsRetrieveRequest; +import com.merge.api.resources.hris.types.Group; +import com.merge.api.resources.hris.types.PaginatedGroupList; +import java.util.concurrent.CompletableFuture; + +public class AsyncGroupsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawGroupsClient rawClient; + + public AsyncGroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawGroupsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawGroupsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture list(GroupsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture list(GroupsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture retrieve(String id, GroupsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture retrieve(String id, GroupsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/groups/AsyncRawGroupsClient.java b/src/main/java/com/merge/api/resources/hris/groups/AsyncRawGroupsClient.java new file mode 100644 index 000000000..556e69cff --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/groups/AsyncRawGroupsClient.java @@ -0,0 +1,260 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.groups; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.groups.requests.GroupsListRequest; +import com.merge.api.resources.hris.groups.requests.GroupsRetrieveRequest; +import com.merge.api.resources.hris.types.Group; +import com.merge.api.resources.hris.types.PaginatedGroupList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawGroupsClient { + protected final ClientOptions clientOptions; + + public AsyncRawGroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture> list() { + return list(GroupsListRequest.builder().build()); + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture> list(GroupsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Group objects. + */ + public CompletableFuture> list( + GroupsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/groups"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonlyUsedAsTeam().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_commonly_used_as_team", + request.getIsCommonlyUsedAsTeam().get(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getNames().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "names", request.getNames().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getTypes().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "types", request.getTypes().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedGroupList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, GroupsRetrieveRequest.builder().build()); + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture> retrieve(String id, GroupsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Group object with the given id. + */ + public CompletableFuture> retrieve( + String id, GroupsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/groups") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Group.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/groups/GroupsClient.java b/src/main/java/com/merge/api/resources/hris/groups/GroupsClient.java index c2659723b..b6710566e 100644 --- a/src/main/java/com/merge/api/resources/hris/groups/GroupsClient.java +++ b/src/main/java/com/merge/api/resources/hris/groups/GroupsClient.java @@ -3,189 +3,69 @@ */ package com.merge.api.resources.hris.groups; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.groups.requests.GroupsListRequest; import com.merge.api.resources.hris.groups.requests.GroupsRetrieveRequest; import com.merge.api.resources.hris.types.Group; import com.merge.api.resources.hris.types.PaginatedGroupList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class GroupsClient { protected final ClientOptions clientOptions; + private final RawGroupsClient rawClient; + public GroupsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawGroupsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawGroupsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Group objects. */ public PaginatedGroupList list() { - return list(GroupsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Group objects. */ public PaginatedGroupList list(GroupsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Group objects. */ public PaginatedGroupList list(GroupsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/groups"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonlyUsedAsTeam().isPresent()) { - httpUrl.addQueryParameter( - "is_commonly_used_as_team", - request.getIsCommonlyUsedAsTeam().get()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getNames().isPresent()) { - httpUrl.addQueryParameter("names", request.getNames().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - if (request.getTypes().isPresent()) { - httpUrl.addQueryParameter("types", request.getTypes().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedGroupList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Group object with the given id. */ public Group retrieve(String id) { - return retrieve(id, GroupsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Group object with the given id. */ public Group retrieve(String id, GroupsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Group object with the given id. */ public Group retrieve(String id, GroupsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/groups") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Group.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/groups/RawGroupsClient.java b/src/main/java/com/merge/api/resources/hris/groups/RawGroupsClient.java new file mode 100644 index 000000000..6d45f7933 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/groups/RawGroupsClient.java @@ -0,0 +1,228 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.groups; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.groups.requests.GroupsListRequest; +import com.merge.api.resources.hris.groups.requests.GroupsRetrieveRequest; +import com.merge.api.resources.hris.types.Group; +import com.merge.api.resources.hris.types.PaginatedGroupList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawGroupsClient { + protected final ClientOptions clientOptions; + + public RawGroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Group objects. + */ + public MergeApiHttpResponse list() { + return list(GroupsListRequest.builder().build()); + } + + /** + * Returns a list of Group objects. + */ + public MergeApiHttpResponse list(GroupsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Group objects. + */ + public MergeApiHttpResponse list(GroupsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/groups"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonlyUsedAsTeam().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_commonly_used_as_team", + request.getIsCommonlyUsedAsTeam().get(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getNames().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "names", request.getNames().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getTypes().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "types", request.getTypes().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedGroupList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Group object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, GroupsRetrieveRequest.builder().build()); + } + + /** + * Returns a Group object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, GroupsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Group object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, GroupsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/groups") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Group.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/groups/requests/GroupsRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/groups/requests/GroupsRetrieveRequest.java index 0a465ae82..8892e46cb 100644 --- a/src/main/java/com/merge/api/resources/hris/groups/requests/GroupsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/groups/requests/GroupsRetrieveRequest.java @@ -22,6 +22,8 @@ public final class GroupsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -30,10 +32,12 @@ public final class GroupsRetrieveRequest { private GroupsRetrieveRequest( Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -47,6 +51,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -76,13 +88,14 @@ public Map getAdditionalProperties() { private boolean equalTo(GroupsRetrieveRequest other) { return includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash(this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -98,6 +111,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -109,6 +124,7 @@ private Builder() {} public Builder from(GroupsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; @@ -125,6 +141,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -148,7 +175,8 @@ public Builder showEnumOrigins(String showEnumOrigins) { } public GroupsRetrieveRequest build() { - return new GroupsRetrieveRequest(includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + return new GroupsRetrieveRequest( + includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/issues/AsyncIssuesClient.java b/src/main/java/com/merge/api/resources/hris/issues/AsyncIssuesClient.java new file mode 100644 index 000000000..f913697d1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/issues/AsyncIssuesClient.java @@ -0,0 +1,64 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.issues; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.issues.requests.IssuesListRequest; +import com.merge.api.resources.hris.types.Issue; +import com.merge.api.resources.hris.types.PaginatedIssueList; +import java.util.concurrent.CompletableFuture; + +public class AsyncIssuesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawIssuesClient rawClient; + + public AsyncIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawIssuesClient withRawResponse() { + return this.rawClient; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/issues/AsyncRawIssuesClient.java b/src/main/java/com/merge/api/resources/hris/issues/AsyncRawIssuesClient.java new file mode 100644 index 000000000..f5d08b803 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/issues/AsyncRawIssuesClient.java @@ -0,0 +1,226 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.issues.requests.IssuesListRequest; +import com.merge.api.resources.hris.types.Issue; +import com.merge.api.resources.hris.types.PaginatedIssueList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawIssuesClient { + protected final ClientOptions clientOptions; + + public AsyncRawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list( + IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/issues/IssuesClient.java b/src/main/java/com/merge/api/resources/hris/issues/IssuesClient.java index 659893f92..661890971 100644 --- a/src/main/java/com/merge/api/resources/hris/issues/IssuesClient.java +++ b/src/main/java/com/merge/api/resources/hris/issues/IssuesClient.java @@ -3,169 +3,61 @@ */ package com.merge.api.resources.hris.issues; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.issues.requests.IssuesListRequest; import com.merge.api.resources.hris.types.Issue; import com.merge.api.resources.hris.types.PaginatedIssueList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class IssuesClient { protected final ClientOptions clientOptions; + private final RawIssuesClient rawClient; + public IssuesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawIssuesClient withRawResponse() { + return this.rawClient; } /** * Gets all issues for Organization. */ public PaginatedIssueList list() { - return list(IssuesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/issues"); - if (request.getAccountToken().isPresent()) { - httpUrl.addQueryParameter("account_token", request.getAccountToken().get()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getFirstIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_after", - request.getFirstIncidentTimeAfter().get().toString()); - } - if (request.getFirstIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_before", - request.getFirstIncidentTimeBefore().get().toString()); - } - if (request.getIncludeMuted().isPresent()) { - httpUrl.addQueryParameter("include_muted", request.getIncludeMuted().get()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getLastIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_after", - request.getLastIncidentTimeAfter().get().toString()); - } - if (request.getLastIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_before", - request.getLastIncidentTimeBefore().get().toString()); - } - if (request.getLinkedAccountId().isPresent()) { - httpUrl.addQueryParameter( - "linked_account_id", request.getLinkedAccountId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Get a specific issue. */ public Issue retrieve(String id) { - return retrieve(id, null); + return this.rawClient.retrieve(id).body(); } /** * Get a specific issue. */ public Issue retrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/issues") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/issues/RawIssuesClient.java b/src/main/java/com/merge/api/resources/hris/issues/RawIssuesClient.java new file mode 100644 index 000000000..8170a26ee --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/issues/RawIssuesClient.java @@ -0,0 +1,194 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.issues.requests.IssuesListRequest; +import com.merge.api.resources.hris.types.Issue; +import com.merge.api.resources.hris.types.PaginatedIssueList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawIssuesClient { + protected final ClientOptions clientOptions; + + public RawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/linkedaccounts/AsyncLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/hris/linkedaccounts/AsyncLinkedAccountsClient.java new file mode 100644 index 000000000..240ec4242 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/linkedaccounts/AsyncLinkedAccountsClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.linkedaccounts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.hris.types.PaginatedAccountDetailsAndActionsList; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkedAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkedAccountsClient rawClient; + + public AsyncLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkedAccountsClient withRawResponse() { + return this.rawClient; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list(LinkedAccountsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/linkedaccounts/AsyncRawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/hris/linkedaccounts/AsyncRawLinkedAccountsClient.java new file mode 100644 index 000000000..4aac81277 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/linkedaccounts/AsyncRawLinkedAccountsClient.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.hris.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/linkedaccounts/LinkedAccountsClient.java b/src/main/java/com/merge/api/resources/hris/linkedaccounts/LinkedAccountsClient.java index 91e8a8bbd..bbbcc6ff1 100644 --- a/src/main/java/com/merge/api/resources/hris/linkedaccounts/LinkedAccountsClient.java +++ b/src/main/java/com/merge/api/resources/hris/linkedaccounts/LinkedAccountsClient.java @@ -3,40 +3,40 @@ */ package com.merge.api.resources.hris.linkedaccounts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.linkedaccounts.requests.LinkedAccountsListRequest; import com.merge.api.resources.hris.types.PaginatedAccountDetailsAndActionsList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkedAccountsClient { protected final ClientOptions clientOptions; + private final RawLinkedAccountsClient rawClient; + public LinkedAccountsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkedAccountsClient withRawResponse() { + return this.rawClient; } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list() { - return list(LinkedAccountsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** @@ -44,80 +44,6 @@ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest requ */ public PaginatedAccountDetailsAndActionsList list( LinkedAccountsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/linked-accounts"); - if (request.getCategory().isPresent()) { - httpUrl.addQueryParameter("category", request.getCategory().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndUserEmailAddress().isPresent()) { - httpUrl.addQueryParameter( - "end_user_email_address", request.getEndUserEmailAddress().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getEndUserOriginId().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_id", request.getEndUserOriginId().get()); - } - if (request.getEndUserOriginIds().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_ids", request.getEndUserOriginIds().get()); - } - if (request.getId().isPresent()) { - httpUrl.addQueryParameter("id", request.getId().get()); - } - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getIncludeDuplicates().isPresent()) { - httpUrl.addQueryParameter( - "include_duplicates", request.getIncludeDuplicates().get().toString()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getIsTestAccount().isPresent()) { - httpUrl.addQueryParameter( - "is_test_account", request.getIsTestAccount().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedAccountDetailsAndActionsList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/linkedaccounts/RawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/hris/linkedaccounts/RawLinkedAccountsClient.java new file mode 100644 index 000000000..107f42282 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/linkedaccounts/RawLinkedAccountsClient.java @@ -0,0 +1,143 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.hris.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public RawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list(LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/linktoken/AsyncLinkTokenClient.java b/src/main/java/com/merge/api/resources/hris/linktoken/AsyncLinkTokenClient.java new file mode 100644 index 000000000..d8da74f66 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/linktoken/AsyncLinkTokenClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.linktoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.hris.types.LinkToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkTokenClient rawClient; + + public AsyncLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/linktoken/AsyncRawLinkTokenClient.java b/src/main/java/com/merge/api/resources/hris/linktoken/AsyncRawLinkTokenClient.java new file mode 100644 index 000000000..4a8c108d1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/linktoken/AsyncRawLinkTokenClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.hris.types.LinkToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create( + EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/linktoken/LinkTokenClient.java b/src/main/java/com/merge/api/resources/hris/linktoken/LinkTokenClient.java index 09cf34fe5..4fa0cf681 100644 --- a/src/main/java/com/merge/api/resources/hris/linktoken/LinkTokenClient.java +++ b/src/main/java/com/merge/api/resources/hris/linktoken/LinkTokenClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.hris.linktoken; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.linktoken.requests.EndUserDetailsRequest; import com.merge.api.resources.hris.types.LinkToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkTokenClient { protected final ClientOptions clientOptions; + private final RawLinkTokenClient rawClient; + public LinkTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkTokenClient withRawResponse() { + return this.rawClient; } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/link-token") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/linktoken/RawLinkTokenClient.java b/src/main/java/com/merge/api/resources/hris/linktoken/RawLinkTokenClient.java new file mode 100644 index 000000000..1ab10fc67 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/linktoken/RawLinkTokenClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.hris.types.LinkToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkTokenClient { + protected final ClientOptions clientOptions; + + public RawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/locations/AsyncLocationsClient.java b/src/main/java/com/merge/api/resources/hris/locations/AsyncLocationsClient.java new file mode 100644 index 000000000..7f172c39e --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/locations/AsyncLocationsClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.locations; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.locations.requests.LocationsListRequest; +import com.merge.api.resources.hris.locations.requests.LocationsRetrieveRequest; +import com.merge.api.resources.hris.types.Location; +import com.merge.api.resources.hris.types.PaginatedLocationList; +import java.util.concurrent.CompletableFuture; + +public class AsyncLocationsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLocationsClient rawClient; + + public AsyncLocationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLocationsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLocationsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Location objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Location objects. + */ + public CompletableFuture list(LocationsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Location objects. + */ + public CompletableFuture list(LocationsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Location object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Location object with the given id. + */ + public CompletableFuture retrieve(String id, LocationsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Location object with the given id. + */ + public CompletableFuture retrieve( + String id, LocationsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/locations/AsyncRawLocationsClient.java b/src/main/java/com/merge/api/resources/hris/locations/AsyncRawLocationsClient.java new file mode 100644 index 000000000..5868bc683 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/locations/AsyncRawLocationsClient.java @@ -0,0 +1,255 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.locations; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.locations.requests.LocationsListRequest; +import com.merge.api.resources.hris.locations.requests.LocationsRetrieveRequest; +import com.merge.api.resources.hris.types.Location; +import com.merge.api.resources.hris.types.PaginatedLocationList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLocationsClient { + protected final ClientOptions clientOptions; + + public AsyncRawLocationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Location objects. + */ + public CompletableFuture> list() { + return list(LocationsListRequest.builder().build()); + } + + /** + * Returns a list of Location objects. + */ + public CompletableFuture> list(LocationsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Location objects. + */ + public CompletableFuture> list( + LocationsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/locations"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getLocationType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "location_type", request.getLocationType().get().toString(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedLocationList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Location object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, LocationsRetrieveRequest.builder().build()); + } + + /** + * Returns a Location object with the given id. + */ + public CompletableFuture> retrieve(String id, LocationsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Location object with the given id. + */ + public CompletableFuture> retrieve( + String id, LocationsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/locations") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Location.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/locations/LocationsClient.java b/src/main/java/com/merge/api/resources/hris/locations/LocationsClient.java index 666274ac0..2809d7515 100644 --- a/src/main/java/com/merge/api/resources/hris/locations/LocationsClient.java +++ b/src/main/java/com/merge/api/resources/hris/locations/LocationsClient.java @@ -3,184 +3,69 @@ */ package com.merge.api.resources.hris.locations; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.locations.requests.LocationsListRequest; import com.merge.api.resources.hris.locations.requests.LocationsRetrieveRequest; import com.merge.api.resources.hris.types.Location; import com.merge.api.resources.hris.types.PaginatedLocationList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LocationsClient { protected final ClientOptions clientOptions; + private final RawLocationsClient rawClient; + public LocationsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLocationsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLocationsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Location objects. */ public PaginatedLocationList list() { - return list(LocationsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Location objects. */ public PaginatedLocationList list(LocationsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Location objects. */ public PaginatedLocationList list(LocationsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/locations"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getLocationType().isPresent()) { - httpUrl.addQueryParameter( - "location_type", request.getLocationType().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedLocationList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Location object with the given id. */ public Location retrieve(String id) { - return retrieve(id, LocationsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Location object with the given id. */ public Location retrieve(String id, LocationsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Location object with the given id. */ public Location retrieve(String id, LocationsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/locations") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Location.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/locations/RawLocationsClient.java b/src/main/java/com/merge/api/resources/hris/locations/RawLocationsClient.java new file mode 100644 index 000000000..7b4d51e58 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/locations/RawLocationsClient.java @@ -0,0 +1,225 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.locations; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.locations.requests.LocationsListRequest; +import com.merge.api.resources.hris.locations.requests.LocationsRetrieveRequest; +import com.merge.api.resources.hris.types.Location; +import com.merge.api.resources.hris.types.PaginatedLocationList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLocationsClient { + protected final ClientOptions clientOptions; + + public RawLocationsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Location objects. + */ + public MergeApiHttpResponse list() { + return list(LocationsListRequest.builder().build()); + } + + /** + * Returns a list of Location objects. + */ + public MergeApiHttpResponse list(LocationsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Location objects. + */ + public MergeApiHttpResponse list( + LocationsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/locations"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getLocationType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "location_type", request.getLocationType().get().toString(), false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedLocationList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Location object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, LocationsRetrieveRequest.builder().build()); + } + + /** + * Returns a Location object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, LocationsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Location object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, LocationsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/locations") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Location.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/locations/requests/LocationsRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/locations/requests/LocationsRetrieveRequest.java index 684e004c8..3ab243996 100644 --- a/src/main/java/com/merge/api/resources/hris/locations/requests/LocationsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/locations/requests/LocationsRetrieveRequest.java @@ -24,6 +24,8 @@ public final class LocationsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -32,10 +34,12 @@ public final class LocationsRetrieveRequest { private LocationsRetrieveRequest( Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -49,6 +53,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -78,13 +90,14 @@ public Map getAdditionalProperties() { private boolean equalTo(LocationsRetrieveRequest other) { return includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash(this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -100,6 +113,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -111,6 +126,7 @@ private Builder() {} public Builder from(LocationsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; @@ -127,6 +143,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -150,7 +177,8 @@ public Builder showEnumOrigins(LocationsRetrieveRequestShowEnumOrigins showEnumO } public LocationsRetrieveRequest build() { - return new LocationsRetrieveRequest(includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + return new LocationsRetrieveRequest( + includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/passthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/hris/passthrough/AsyncPassthroughClient.java new file mode 100644 index 000000000..207270a8d --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/passthrough/AsyncPassthroughClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.passthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.DataPassthroughRequest; +import com.merge.api.resources.hris.types.RemoteResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPassthroughClient rawClient; + + public AsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/passthrough/AsyncRawPassthroughClient.java b/src/main/java/com/merge/api/resources/hris/passthrough/AsyncRawPassthroughClient.java new file mode 100644 index 000000000..e99f36c6c --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/passthrough/AsyncRawPassthroughClient.java @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.DataPassthroughRequest; +import com.merge.api.resources.hris.types.RemoteResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/passthrough/PassthroughClient.java b/src/main/java/com/merge/api/resources/hris/passthrough/PassthroughClient.java index 54dae4fd7..27779766a 100644 --- a/src/main/java/com/merge/api/resources/hris/passthrough/PassthroughClient.java +++ b/src/main/java/com/merge/api/resources/hris/passthrough/PassthroughClient.java @@ -3,75 +3,39 @@ */ package com.merge.api.resources.hris.passthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.types.DataPassthroughRequest; import com.merge.api.resources.hris.types.RemoteResponse; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PassthroughClient { protected final ClientOptions clientOptions; + private final RawPassthroughClient rawClient; + public PassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPassthroughClient withRawResponse() { + return this.rawClient; } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/passthrough/RawPassthroughClient.java b/src/main/java/com/merge/api/resources/hris/passthrough/RawPassthroughClient.java new file mode 100644 index 000000000..5d4838fd5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/passthrough/RawPassthroughClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.DataPassthroughRequest; +import com.merge.api.resources.hris.types.RemoteResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPassthroughClient { + protected final ClientOptions clientOptions; + + public RawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/paygroups/AsyncPayGroupsClient.java b/src/main/java/com/merge/api/resources/hris/paygroups/AsyncPayGroupsClient.java new file mode 100644 index 000000000..b88e80d02 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/paygroups/AsyncPayGroupsClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.paygroups; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.paygroups.requests.PayGroupsListRequest; +import com.merge.api.resources.hris.paygroups.requests.PayGroupsRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedPayGroupList; +import com.merge.api.resources.hris.types.PayGroup; +import java.util.concurrent.CompletableFuture; + +public class AsyncPayGroupsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPayGroupsClient rawClient; + + public AsyncPayGroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPayGroupsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPayGroupsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of PayGroup objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of PayGroup objects. + */ + public CompletableFuture list(PayGroupsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of PayGroup objects. + */ + public CompletableFuture list(PayGroupsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a PayGroup object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a PayGroup object with the given id. + */ + public CompletableFuture retrieve(String id, PayGroupsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a PayGroup object with the given id. + */ + public CompletableFuture retrieve( + String id, PayGroupsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/paygroups/AsyncRawPayGroupsClient.java b/src/main/java/com/merge/api/resources/hris/paygroups/AsyncRawPayGroupsClient.java new file mode 100644 index 000000000..394ef05f3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/paygroups/AsyncRawPayGroupsClient.java @@ -0,0 +1,229 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.paygroups; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.paygroups.requests.PayGroupsListRequest; +import com.merge.api.resources.hris.paygroups.requests.PayGroupsRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedPayGroupList; +import com.merge.api.resources.hris.types.PayGroup; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPayGroupsClient { + protected final ClientOptions clientOptions; + + public AsyncRawPayGroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of PayGroup objects. + */ + public CompletableFuture> list() { + return list(PayGroupsListRequest.builder().build()); + } + + /** + * Returns a list of PayGroup objects. + */ + public CompletableFuture> list(PayGroupsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of PayGroup objects. + */ + public CompletableFuture> list( + PayGroupsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/pay-groups"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPayGroupList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a PayGroup object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, PayGroupsRetrieveRequest.builder().build()); + } + + /** + * Returns a PayGroup object with the given id. + */ + public CompletableFuture> retrieve(String id, PayGroupsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a PayGroup object with the given id. + */ + public CompletableFuture> retrieve( + String id, PayGroupsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/pay-groups") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PayGroup.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/paygroups/PayGroupsClient.java b/src/main/java/com/merge/api/resources/hris/paygroups/PayGroupsClient.java index 4f2206700..20ae86dda 100644 --- a/src/main/java/com/merge/api/resources/hris/paygroups/PayGroupsClient.java +++ b/src/main/java/com/merge/api/resources/hris/paygroups/PayGroupsClient.java @@ -3,164 +3,69 @@ */ package com.merge.api.resources.hris.paygroups; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.paygroups.requests.PayGroupsListRequest; import com.merge.api.resources.hris.paygroups.requests.PayGroupsRetrieveRequest; import com.merge.api.resources.hris.types.PaginatedPayGroupList; import com.merge.api.resources.hris.types.PayGroup; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PayGroupsClient { protected final ClientOptions clientOptions; + private final RawPayGroupsClient rawClient; + public PayGroupsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPayGroupsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPayGroupsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of PayGroup objects. */ public PaginatedPayGroupList list() { - return list(PayGroupsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of PayGroup objects. */ public PaginatedPayGroupList list(PayGroupsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of PayGroup objects. */ public PaginatedPayGroupList list(PayGroupsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/pay-groups"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPayGroupList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a PayGroup object with the given id. */ public PayGroup retrieve(String id) { - return retrieve(id, PayGroupsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a PayGroup object with the given id. */ public PayGroup retrieve(String id, PayGroupsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a PayGroup object with the given id. */ public PayGroup retrieve(String id, PayGroupsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/pay-groups") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PayGroup.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/paygroups/RawPayGroupsClient.java b/src/main/java/com/merge/api/resources/hris/paygroups/RawPayGroupsClient.java new file mode 100644 index 000000000..d5f89cc1f --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/paygroups/RawPayGroupsClient.java @@ -0,0 +1,199 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.paygroups; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.paygroups.requests.PayGroupsListRequest; +import com.merge.api.resources.hris.paygroups.requests.PayGroupsRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedPayGroupList; +import com.merge.api.resources.hris.types.PayGroup; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPayGroupsClient { + protected final ClientOptions clientOptions; + + public RawPayGroupsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of PayGroup objects. + */ + public MergeApiHttpResponse list() { + return list(PayGroupsListRequest.builder().build()); + } + + /** + * Returns a list of PayGroup objects. + */ + public MergeApiHttpResponse list(PayGroupsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of PayGroup objects. + */ + public MergeApiHttpResponse list( + PayGroupsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/pay-groups"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPayGroupList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a PayGroup object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, PayGroupsRetrieveRequest.builder().build()); + } + + /** + * Returns a PayGroup object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, PayGroupsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a PayGroup object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, PayGroupsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/pay-groups") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PayGroup.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/paygroups/requests/PayGroupsRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/paygroups/requests/PayGroupsRetrieveRequest.java index 88c31349a..824d471dc 100644 --- a/src/main/java/com/merge/api/resources/hris/paygroups/requests/PayGroupsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/paygroups/requests/PayGroupsRetrieveRequest.java @@ -22,10 +22,16 @@ public final class PayGroupsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private PayGroupsRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private PayGroupsRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(PayGroupsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(PayGroupsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public PayGroupsRetrieveRequest build() { - return new PayGroupsRetrieveRequest(includeRemoteData, additionalProperties); + return new PayGroupsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/payrollruns/AsyncPayrollRunsClient.java b/src/main/java/com/merge/api/resources/hris/payrollruns/AsyncPayrollRunsClient.java new file mode 100644 index 000000000..9bc520144 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/payrollruns/AsyncPayrollRunsClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.payrollruns; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.payrollruns.requests.PayrollRunsListRequest; +import com.merge.api.resources.hris.payrollruns.requests.PayrollRunsRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedPayrollRunList; +import com.merge.api.resources.hris.types.PayrollRun; +import java.util.concurrent.CompletableFuture; + +public class AsyncPayrollRunsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPayrollRunsClient rawClient; + + public AsyncPayrollRunsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPayrollRunsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPayrollRunsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of PayrollRun objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of PayrollRun objects. + */ + public CompletableFuture list(PayrollRunsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of PayrollRun objects. + */ + public CompletableFuture list( + PayrollRunsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a PayrollRun object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a PayrollRun object with the given id. + */ + public CompletableFuture retrieve(String id, PayrollRunsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a PayrollRun object with the given id. + */ + public CompletableFuture retrieve( + String id, PayrollRunsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/payrollruns/AsyncRawPayrollRunsClient.java b/src/main/java/com/merge/api/resources/hris/payrollruns/AsyncRawPayrollRunsClient.java new file mode 100644 index 000000000..ef455a7c5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/payrollruns/AsyncRawPayrollRunsClient.java @@ -0,0 +1,273 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.payrollruns; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.payrollruns.requests.PayrollRunsListRequest; +import com.merge.api.resources.hris.payrollruns.requests.PayrollRunsRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedPayrollRunList; +import com.merge.api.resources.hris.types.PayrollRun; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPayrollRunsClient { + protected final ClientOptions clientOptions; + + public AsyncRawPayrollRunsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of PayrollRun objects. + */ + public CompletableFuture> list() { + return list(PayrollRunsListRequest.builder().build()); + } + + /** + * Returns a list of PayrollRun objects. + */ + public CompletableFuture> list(PayrollRunsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of PayrollRun objects. + */ + public CompletableFuture> list( + PayrollRunsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/payroll-runs"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_after", request.getEndedAfter().get().toString(), false); + } + if (request.getEndedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_before", request.getEndedBefore().get().toString(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getRunType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_type", request.getRunType().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedPayrollRunList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a PayrollRun object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, PayrollRunsRetrieveRequest.builder().build()); + } + + /** + * Returns a PayrollRun object with the given id. + */ + public CompletableFuture> retrieve(String id, PayrollRunsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a PayrollRun object with the given id. + */ + public CompletableFuture> retrieve( + String id, PayrollRunsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/payroll-runs") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PayrollRun.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/payrollruns/PayrollRunsClient.java b/src/main/java/com/merge/api/resources/hris/payrollruns/PayrollRunsClient.java index d761dc5c9..ae6d96f1e 100644 --- a/src/main/java/com/merge/api/resources/hris/payrollruns/PayrollRunsClient.java +++ b/src/main/java/com/merge/api/resources/hris/payrollruns/PayrollRunsClient.java @@ -3,199 +3,69 @@ */ package com.merge.api.resources.hris.payrollruns; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.payrollruns.requests.PayrollRunsListRequest; import com.merge.api.resources.hris.payrollruns.requests.PayrollRunsRetrieveRequest; import com.merge.api.resources.hris.types.PaginatedPayrollRunList; import com.merge.api.resources.hris.types.PayrollRun; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PayrollRunsClient { protected final ClientOptions clientOptions; + private final RawPayrollRunsClient rawClient; + public PayrollRunsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPayrollRunsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPayrollRunsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of PayrollRun objects. */ public PaginatedPayrollRunList list() { - return list(PayrollRunsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of PayrollRun objects. */ public PaginatedPayrollRunList list(PayrollRunsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of PayrollRun objects. */ public PaginatedPayrollRunList list(PayrollRunsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/payroll-runs"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndedAfter().isPresent()) { - httpUrl.addQueryParameter( - "ended_after", request.getEndedAfter().get().toString()); - } - if (request.getEndedBefore().isPresent()) { - httpUrl.addQueryParameter( - "ended_before", request.getEndedBefore().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getRunType().isPresent()) { - httpUrl.addQueryParameter("run_type", request.getRunType().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - if (request.getStartedAfter().isPresent()) { - httpUrl.addQueryParameter( - "started_after", request.getStartedAfter().get().toString()); - } - if (request.getStartedBefore().isPresent()) { - httpUrl.addQueryParameter( - "started_before", request.getStartedBefore().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPayrollRunList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a PayrollRun object with the given id. */ public PayrollRun retrieve(String id) { - return retrieve(id, PayrollRunsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a PayrollRun object with the given id. */ public PayrollRun retrieve(String id, PayrollRunsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a PayrollRun object with the given id. */ public PayrollRun retrieve(String id, PayrollRunsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/payroll-runs") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PayrollRun.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/payrollruns/RawPayrollRunsClient.java b/src/main/java/com/merge/api/resources/hris/payrollruns/RawPayrollRunsClient.java new file mode 100644 index 000000000..de6849240 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/payrollruns/RawPayrollRunsClient.java @@ -0,0 +1,241 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.payrollruns; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.payrollruns.requests.PayrollRunsListRequest; +import com.merge.api.resources.hris.payrollruns.requests.PayrollRunsRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedPayrollRunList; +import com.merge.api.resources.hris.types.PayrollRun; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPayrollRunsClient { + protected final ClientOptions clientOptions; + + public RawPayrollRunsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of PayrollRun objects. + */ + public MergeApiHttpResponse list() { + return list(PayrollRunsListRequest.builder().build()); + } + + /** + * Returns a list of PayrollRun objects. + */ + public MergeApiHttpResponse list(PayrollRunsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of PayrollRun objects. + */ + public MergeApiHttpResponse list( + PayrollRunsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/payroll-runs"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_after", request.getEndedAfter().get().toString(), false); + } + if (request.getEndedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_before", request.getEndedBefore().get().toString(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getRunType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_type", request.getRunType().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedPayrollRunList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a PayrollRun object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, PayrollRunsRetrieveRequest.builder().build()); + } + + /** + * Returns a PayrollRun object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, PayrollRunsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a PayrollRun object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, PayrollRunsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/payroll-runs") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PayrollRun.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/payrollruns/requests/PayrollRunsRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/payrollruns/requests/PayrollRunsRetrieveRequest.java index 49d673072..c4733318a 100644 --- a/src/main/java/com/merge/api/resources/hris/payrollruns/requests/PayrollRunsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/payrollruns/requests/PayrollRunsRetrieveRequest.java @@ -24,6 +24,8 @@ public final class PayrollRunsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -32,10 +34,12 @@ public final class PayrollRunsRetrieveRequest { private PayrollRunsRetrieveRequest( Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -49,6 +53,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -78,13 +90,14 @@ public Map getAdditionalProperties() { private boolean equalTo(PayrollRunsRetrieveRequest other) { return includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash(this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -100,6 +113,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -111,6 +126,7 @@ private Builder() {} public Builder from(PayrollRunsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; @@ -127,6 +143,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -151,7 +178,7 @@ public Builder showEnumOrigins(PayrollRunsRetrieveRequestShowEnumOrigins showEnu public PayrollRunsRetrieveRequest build() { return new PayrollRunsRetrieveRequest( - includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/regeneratekey/AsyncRawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/hris/regeneratekey/AsyncRawRegenerateKeyClient.java new file mode 100644 index 000000000..bdc6ffcb9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/regeneratekey/AsyncRawRegenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.hris.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/regeneratekey/AsyncRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/hris/regeneratekey/AsyncRegenerateKeyClient.java new file mode 100644 index 000000000..f06199235 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/regeneratekey/AsyncRegenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.regeneratekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.hris.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncRegenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawRegenerateKeyClient rawClient; + + public AsyncRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawRegenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/regeneratekey/RawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/hris/regeneratekey/RawRegenerateKeyClient.java new file mode 100644 index 000000000..0f0672356 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/regeneratekey/RawRegenerateKeyClient.java @@ -0,0 +1,82 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.hris.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/regeneratekey/RegenerateKeyClient.java b/src/main/java/com/merge/api/resources/hris/regeneratekey/RegenerateKeyClient.java index 4223fda41..c0125e26a 100644 --- a/src/main/java/com/merge/api/resources/hris/regeneratekey/RegenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/hris/regeneratekey/RegenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.hris.regeneratekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.regeneratekey.requests.RemoteKeyForRegenerationRequest; import com.merge.api.resources.hris.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class RegenerateKeyClient { protected final ClientOptions clientOptions; + private final RawRegenerateKeyClient rawClient; + public RegenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawRegenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/regenerate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/scopes/AsyncRawScopesClient.java b/src/main/java/com/merge/api/resources/hris/scopes/AsyncRawScopesClient.java new file mode 100644 index 000000000..fd5e1b944 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/scopes/AsyncRawScopesClient.java @@ -0,0 +1,217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.hris.types.CommonModelScopeApi; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawScopesClient { + protected final ClientOptions clientOptions; + + public AsyncRawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/scopes/AsyncScopesClient.java b/src/main/java/com/merge/api/resources/hris/scopes/AsyncScopesClient.java new file mode 100644 index 000000000..f5b6f27c1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/scopes/AsyncScopesClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.scopes; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.hris.types.CommonModelScopeApi; +import java.util.concurrent.CompletableFuture; + +public class AsyncScopesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawScopesClient rawClient; + + public AsyncScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawScopesClient withRawResponse() { + return this.rawClient; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve() { + return this.rawClient.defaultScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.defaultScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve() { + return this.rawClient.linkedAccountScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return this.rawClient.linkedAccountScopesCreate(request).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/scopes/RawScopesClient.java b/src/main/java/com/merge/api/resources/hris/scopes/RawScopesClient.java new file mode 100644 index 000000000..c6733ca07 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/scopes/RawScopesClient.java @@ -0,0 +1,172 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.hris.types.CommonModelScopeApi; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawScopesClient { + protected final ClientOptions clientOptions; + + public RawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/scopes/ScopesClient.java b/src/main/java/com/merge/api/resources/hris/scopes/ScopesClient.java index 6987b0e72..a5e55e10c 100644 --- a/src/main/java/com/merge/api/resources/hris/scopes/ScopesClient.java +++ b/src/main/java/com/merge/api/resources/hris/scopes/ScopesClient.java @@ -3,118 +3,61 @@ */ package com.merge.api.resources.hris.scopes; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; import com.merge.api.resources.hris.types.CommonModelScopeApi; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ScopesClient { protected final ClientOptions clientOptions; + private final RawScopesClient rawClient; + public ScopesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawScopesClient withRawResponse() { + return this.rawClient; } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve() { - return defaultScopesRetrieve(null); + return this.rawClient.defaultScopesRetrieve().body(); } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/default-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.defaultScopesRetrieve(requestOptions).body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve() { - return linkedAccountScopesRetrieve(null); + return this.rawClient.linkedAccountScopesRetrieve().body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/linked-account-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).body(); } /** * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more */ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelScopeDeserializerRequest request) { - return linkedAccountScopesCreate(request, null); + return this.rawClient.linkedAccountScopesCreate(request).body(); } /** @@ -122,40 +65,6 @@ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelSco */ public CommonModelScopeApi linkedAccountScopesCreate( LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/linked-account-scopes") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/syncstatus/AsyncRawSyncStatusClient.java b/src/main/java/com/merge/api/resources/hris/syncstatus/AsyncRawSyncStatusClient.java new file mode 100644 index 000000000..cd77a4bb3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/syncstatus/AsyncRawSyncStatusClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.hris.types.PaginatedSyncStatusList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawSyncStatusClient { + protected final ClientOptions clientOptions; + + public AsyncRawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedSyncStatusList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/syncstatus/AsyncSyncStatusClient.java b/src/main/java/com/merge/api/resources/hris/syncstatus/AsyncSyncStatusClient.java new file mode 100644 index 000000000..8f3a5baf5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/syncstatus/AsyncSyncStatusClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.syncstatus; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.hris.types.PaginatedSyncStatusList; +import java.util.concurrent.CompletableFuture; + +public class AsyncSyncStatusClient { + protected final ClientOptions clientOptions; + + private final AsyncRawSyncStatusClient rawClient; + + public AsyncSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawSyncStatusClient withRawResponse() { + return this.rawClient; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list(SyncStatusListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list( + SyncStatusListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/syncstatus/RawSyncStatusClient.java b/src/main/java/com/merge/api/resources/hris/syncstatus/RawSyncStatusClient.java new file mode 100644 index 000000000..3d8bc9fe8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/syncstatus/RawSyncStatusClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.hris.types.PaginatedSyncStatusList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawSyncStatusClient { + protected final ClientOptions clientOptions; + + public RawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/syncstatus/SyncStatusClient.java b/src/main/java/com/merge/api/resources/hris/syncstatus/SyncStatusClient.java index 02e60fd11..d6f5f55ba 100644 --- a/src/main/java/com/merge/api/resources/hris/syncstatus/SyncStatusClient.java +++ b/src/main/java/com/merge/api/resources/hris/syncstatus/SyncStatusClient.java @@ -3,78 +3,46 @@ */ package com.merge.api.resources.hris.syncstatus; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.syncstatus.requests.SyncStatusListRequest; import com.merge.api.resources.hris.types.PaginatedSyncStatusList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class SyncStatusClient { protected final ClientOptions clientOptions; + private final RawSyncStatusClient rawClient; + public SyncStatusClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawSyncStatusClient withRawResponse() { + return this.rawClient; } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list() { - return list(SyncStatusListRequest.builder().build()); + return this.rawClient.list().body(); } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/sync-status"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/teams/AsyncRawTeamsClient.java b/src/main/java/com/merge/api/resources/hris/teams/AsyncRawTeamsClient.java new file mode 100644 index 000000000..08416b776 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/teams/AsyncRawTeamsClient.java @@ -0,0 +1,241 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.teams; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.teams.requests.TeamsListRequest; +import com.merge.api.resources.hris.teams.requests.TeamsRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedTeamList; +import com.merge.api.resources.hris.types.Team; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTeamsClient { + protected final ClientOptions clientOptions; + + public AsyncRawTeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture> list() { + return list(TeamsListRequest.builder().build()); + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture> list(TeamsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture> list( + TeamsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/teams"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getParentTeamId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "parent_team_id", request.getParentTeamId().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTeamList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TeamsRetrieveRequest.builder().build()); + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture> retrieve(String id, TeamsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture> retrieve( + String id, TeamsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/teams") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/teams/AsyncTeamsClient.java b/src/main/java/com/merge/api/resources/hris/teams/AsyncTeamsClient.java new file mode 100644 index 000000000..0cc15958a --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/teams/AsyncTeamsClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.teams; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.teams.requests.TeamsListRequest; +import com.merge.api.resources.hris.teams.requests.TeamsRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedTeamList; +import com.merge.api.resources.hris.types.Team; +import java.util.concurrent.CompletableFuture; + +public class AsyncTeamsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTeamsClient rawClient; + + public AsyncTeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTeamsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTeamsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture list(TeamsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture list(TeamsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture retrieve(String id, TeamsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture retrieve(String id, TeamsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/teams/RawTeamsClient.java b/src/main/java/com/merge/api/resources/hris/teams/RawTeamsClient.java new file mode 100644 index 000000000..6e8a26944 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/teams/RawTeamsClient.java @@ -0,0 +1,208 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.teams; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.teams.requests.TeamsListRequest; +import com.merge.api.resources.hris.teams.requests.TeamsRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedTeamList; +import com.merge.api.resources.hris.types.Team; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTeamsClient { + protected final ClientOptions clientOptions; + + public RawTeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Team objects. + */ + public MergeApiHttpResponse list() { + return list(TeamsListRequest.builder().build()); + } + + /** + * Returns a list of Team objects. + */ + public MergeApiHttpResponse list(TeamsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Team objects. + */ + public MergeApiHttpResponse list(TeamsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/teams"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getParentTeamId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "parent_team_id", request.getParentTeamId().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTeamList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Team object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TeamsRetrieveRequest.builder().build()); + } + + /** + * Returns a Team object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TeamsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Team object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TeamsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/teams") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/teams/TeamsClient.java b/src/main/java/com/merge/api/resources/hris/teams/TeamsClient.java index be855d6aa..24d6c299c 100644 --- a/src/main/java/com/merge/api/resources/hris/teams/TeamsClient.java +++ b/src/main/java/com/merge/api/resources/hris/teams/TeamsClient.java @@ -3,174 +3,69 @@ */ package com.merge.api.resources.hris.teams; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.teams.requests.TeamsListRequest; import com.merge.api.resources.hris.teams.requests.TeamsRetrieveRequest; import com.merge.api.resources.hris.types.PaginatedTeamList; import com.merge.api.resources.hris.types.Team; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TeamsClient { protected final ClientOptions clientOptions; + private final RawTeamsClient rawClient; + public TeamsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTeamsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTeamsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Team objects. */ public PaginatedTeamList list() { - return list(TeamsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Team objects. */ public PaginatedTeamList list(TeamsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Team objects. */ public PaginatedTeamList list(TeamsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/teams"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getParentTeamId().isPresent()) { - httpUrl.addQueryParameter( - "parent_team_id", request.getParentTeamId().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTeamList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Team object with the given id. */ public Team retrieve(String id) { - return retrieve(id, TeamsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Team object with the given id. */ public Team retrieve(String id, TeamsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Team object with the given id. */ public Team retrieve(String id, TeamsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/teams") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/teams/requests/TeamsListRequest.java b/src/main/java/com/merge/api/resources/hris/teams/requests/TeamsListRequest.java index 91437cb20..496293107 100644 --- a/src/main/java/com/merge/api/resources/hris/teams/requests/TeamsListRequest.java +++ b/src/main/java/com/merge/api/resources/hris/teams/requests/TeamsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,14 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TeamsListRequest.Builder.class) public final class TeamsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -48,10 +50,10 @@ public final class TeamsListRequest { private final Map additionalProperties; private TeamsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -61,10 +63,10 @@ private TeamsListRequest( Optional parentTeamId, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -76,6 +78,14 @@ private TeamsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -100,14 +110,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -184,10 +186,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(TeamsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -201,10 +203,10 @@ private boolean equalTo(TeamsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -226,14 +228,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -256,10 +258,10 @@ public static final class Builder { private Builder() {} public Builder from(TeamsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -271,6 +273,22 @@ public Builder from(TeamsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -304,17 +322,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -405,10 +412,10 @@ public Builder remoteId(String remoteId) { public TeamsListRequest build() { return new TeamsListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/hris/teams/requests/TeamsRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/teams/requests/TeamsRetrieveRequest.java index 93812850b..6e22a5d5b 100644 --- a/src/main/java/com/merge/api/resources/hris/teams/requests/TeamsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/teams/requests/TeamsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TeamsRetrieveRequest.Builder.class) public final class TeamsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private TeamsRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private TeamsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(TeamsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(TeamsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public TeamsRetrieveRequest build() { - return new TeamsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new TeamsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/timeoff/AsyncRawTimeOffClient.java b/src/main/java/com/merge/api/resources/hris/timeoff/AsyncRawTimeOffClient.java new file mode 100644 index 000000000..2ad027db7 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timeoff/AsyncRawTimeOffClient.java @@ -0,0 +1,429 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timeoff; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.timeoff.requests.TimeOffEndpointRequest; +import com.merge.api.resources.hris.timeoff.requests.TimeOffListRequest; +import com.merge.api.resources.hris.timeoff.requests.TimeOffRetrieveRequest; +import com.merge.api.resources.hris.types.MetaResponse; +import com.merge.api.resources.hris.types.PaginatedTimeOffList; +import com.merge.api.resources.hris.types.TimeOff; +import com.merge.api.resources.hris.types.TimeOffResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTimeOffClient { + protected final ClientOptions clientOptions; + + public AsyncRawTimeOffClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of TimeOff objects. + */ + public CompletableFuture> list() { + return list(TimeOffListRequest.builder().build()); + } + + /** + * Returns a list of TimeOff objects. + */ + public CompletableFuture> list(TimeOffListRequest request) { + return list(request, null); + } + + /** + * Returns a list of TimeOff objects. + */ + public CompletableFuture> list( + TimeOffListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off"); + if (request.getApproverId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "approver_id", request.getApproverId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getEndedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_after", request.getEndedAfter().get().toString(), false); + } + if (request.getEndedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_before", request.getEndedBefore().get().toString(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getRequestType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "request_type", request.getRequestType().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTimeOffList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a TimeOff object with the given values. + */ + public CompletableFuture> create(TimeOffEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a TimeOff object with the given values. + */ + public CompletableFuture> create( + TimeOffEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimeOffResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a TimeOff object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TimeOffRetrieveRequest.builder().build()); + } + + /** + * Returns a TimeOff object with the given id. + */ + public CompletableFuture> retrieve(String id, TimeOffRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a TimeOff object with the given id. + */ + public CompletableFuture> retrieve( + String id, TimeOffRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimeOff.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for TimeOff POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for TimeOff POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timeoff/AsyncTimeOffClient.java b/src/main/java/com/merge/api/resources/hris/timeoff/AsyncTimeOffClient.java new file mode 100644 index 000000000..5a7d250ef --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timeoff/AsyncTimeOffClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timeoff; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.timeoff.requests.TimeOffEndpointRequest; +import com.merge.api.resources.hris.timeoff.requests.TimeOffListRequest; +import com.merge.api.resources.hris.timeoff.requests.TimeOffRetrieveRequest; +import com.merge.api.resources.hris.types.MetaResponse; +import com.merge.api.resources.hris.types.PaginatedTimeOffList; +import com.merge.api.resources.hris.types.TimeOff; +import com.merge.api.resources.hris.types.TimeOffResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncTimeOffClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTimeOffClient rawClient; + + public AsyncTimeOffClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTimeOffClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTimeOffClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of TimeOff objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of TimeOff objects. + */ + public CompletableFuture list(TimeOffListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of TimeOff objects. + */ + public CompletableFuture list(TimeOffListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a TimeOff object with the given values. + */ + public CompletableFuture create(TimeOffEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a TimeOff object with the given values. + */ + public CompletableFuture create(TimeOffEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a TimeOff object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a TimeOff object with the given id. + */ + public CompletableFuture retrieve(String id, TimeOffRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a TimeOff object with the given id. + */ + public CompletableFuture retrieve( + String id, TimeOffRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for TimeOff POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for TimeOff POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timeoff/RawTimeOffClient.java b/src/main/java/com/merge/api/resources/hris/timeoff/RawTimeOffClient.java new file mode 100644 index 000000000..9c72e44ed --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timeoff/RawTimeOffClient.java @@ -0,0 +1,369 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timeoff; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.timeoff.requests.TimeOffEndpointRequest; +import com.merge.api.resources.hris.timeoff.requests.TimeOffListRequest; +import com.merge.api.resources.hris.timeoff.requests.TimeOffRetrieveRequest; +import com.merge.api.resources.hris.types.MetaResponse; +import com.merge.api.resources.hris.types.PaginatedTimeOffList; +import com.merge.api.resources.hris.types.TimeOff; +import com.merge.api.resources.hris.types.TimeOffResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTimeOffClient { + protected final ClientOptions clientOptions; + + public RawTimeOffClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of TimeOff objects. + */ + public MergeApiHttpResponse list() { + return list(TimeOffListRequest.builder().build()); + } + + /** + * Returns a list of TimeOff objects. + */ + public MergeApiHttpResponse list(TimeOffListRequest request) { + return list(request, null); + } + + /** + * Returns a list of TimeOff objects. + */ + public MergeApiHttpResponse list(TimeOffListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off"); + if (request.getApproverId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "approver_id", request.getApproverId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getEndedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_after", request.getEndedAfter().get().toString(), false); + } + if (request.getEndedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_before", request.getEndedBefore().get().toString(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getRequestType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "request_type", request.getRequestType().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTimeOffList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a TimeOff object with the given values. + */ + public MergeApiHttpResponse create(TimeOffEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a TimeOff object with the given values. + */ + public MergeApiHttpResponse create(TimeOffEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimeOffResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a TimeOff object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TimeOffRetrieveRequest.builder().build()); + } + + /** + * Returns a TimeOff object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TimeOffRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a TimeOff object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, TimeOffRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimeOff.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for TimeOff POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for TimeOff POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timeoff/TimeOffClient.java b/src/main/java/com/merge/api/resources/hris/timeoff/TimeOffClient.java index 428a57a5e..86dbf50a2 100644 --- a/src/main/java/com/merge/api/resources/hris/timeoff/TimeOffClient.java +++ b/src/main/java/com/merge/api/resources/hris/timeoff/TimeOffClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.hris.timeoff; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.timeoff.requests.TimeOffEndpointRequest; import com.merge.api.resources.hris.timeoff.requests.TimeOffListRequest; @@ -16,306 +12,91 @@ import com.merge.api.resources.hris.types.PaginatedTimeOffList; import com.merge.api.resources.hris.types.TimeOff; import com.merge.api.resources.hris.types.TimeOffResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TimeOffClient { protected final ClientOptions clientOptions; + private final RawTimeOffClient rawClient; + public TimeOffClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTimeOffClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTimeOffClient withRawResponse() { + return this.rawClient; } /** * Returns a list of TimeOff objects. */ public PaginatedTimeOffList list() { - return list(TimeOffListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of TimeOff objects. */ public PaginatedTimeOffList list(TimeOffListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of TimeOff objects. */ public PaginatedTimeOffList list(TimeOffListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/time-off"); - if (request.getApproverId().isPresent()) { - httpUrl.addQueryParameter("approver_id", request.getApproverId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmployeeId().isPresent()) { - httpUrl.addQueryParameter("employee_id", request.getEmployeeId().get()); - } - if (request.getEndedAfter().isPresent()) { - httpUrl.addQueryParameter( - "ended_after", request.getEndedAfter().get().toString()); - } - if (request.getEndedBefore().isPresent()) { - httpUrl.addQueryParameter( - "ended_before", request.getEndedBefore().get().toString()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getRequestType().isPresent()) { - httpUrl.addQueryParameter( - "request_type", request.getRequestType().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - if (request.getStartedAfter().isPresent()) { - httpUrl.addQueryParameter( - "started_after", request.getStartedAfter().get().toString()); - } - if (request.getStartedBefore().isPresent()) { - httpUrl.addQueryParameter( - "started_before", request.getStartedBefore().get().toString()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTimeOffList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a TimeOff object with the given values. */ public TimeOffResponse create(TimeOffEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a TimeOff object with the given values. */ public TimeOffResponse create(TimeOffEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/time-off"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimeOffResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a TimeOff object with the given id. */ public TimeOff retrieve(String id) { - return retrieve(id, TimeOffRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a TimeOff object with the given id. */ public TimeOff retrieve(String id, TimeOffRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a TimeOff object with the given id. */ public TimeOff retrieve(String id, TimeOffRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/time-off") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimeOff.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for TimeOff POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for TimeOff POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/time-off/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/timeoff/requests/TimeOffListRequest.java b/src/main/java/com/merge/api/resources/hris/timeoff/requests/TimeOffListRequest.java index 6502ca746..faa3cc66c 100644 --- a/src/main/java/com/merge/api/resources/hris/timeoff/requests/TimeOffListRequest.java +++ b/src/main/java/com/merge/api/resources/hris/timeoff/requests/TimeOffListRequest.java @@ -12,13 +12,15 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.hris.timeoff.types.TimeOffListRequestExpand; +import com.merge.api.resources.hris.timeoff.types.TimeOffListRequestExpandItem; import com.merge.api.resources.hris.timeoff.types.TimeOffListRequestRemoteFields; import com.merge.api.resources.hris.timeoff.types.TimeOffListRequestRequestType; import com.merge.api.resources.hris.timeoff.types.TimeOffListRequestShowEnumOrigins; import com.merge.api.resources.hris.timeoff.types.TimeOffListRequestStatus; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -26,6 +28,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TimeOffListRequest.Builder.class) public final class TimeOffListRequest { + private final Optional> expand; + private final Optional approverId; private final Optional createdAfter; @@ -40,8 +44,6 @@ public final class TimeOffListRequest { private final Optional endedBefore; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -71,6 +73,7 @@ public final class TimeOffListRequest { private final Map additionalProperties; private TimeOffListRequest( + Optional> expand, Optional approverId, Optional createdAfter, Optional createdBefore, @@ -78,7 +81,6 @@ private TimeOffListRequest( Optional employeeId, Optional endedAfter, Optional endedBefore, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -93,6 +95,7 @@ private TimeOffListRequest( Optional startedBefore, Optional status, Map additionalProperties) { + this.expand = expand; this.approverId = approverId; this.createdAfter = createdAfter; this.createdBefore = createdBefore; @@ -100,7 +103,6 @@ private TimeOffListRequest( this.employeeId = employeeId; this.endedAfter = endedAfter; this.endedBefore = endedBefore; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -117,6 +119,14 @@ private TimeOffListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return time off for this approver. */ @@ -173,14 +183,6 @@ public Optional getEndedBefore() { return endedBefore; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -312,14 +314,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(TimeOffListRequest other) { - return approverId.equals(other.approverId) + return expand.equals(other.expand) + && approverId.equals(other.approverId) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && employeeId.equals(other.employeeId) && endedAfter.equals(other.endedAfter) && endedBefore.equals(other.endedBefore) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -338,6 +340,7 @@ private boolean equalTo(TimeOffListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.approverId, this.createdAfter, this.createdBefore, @@ -345,7 +348,6 @@ public int hashCode() { this.employeeId, this.endedAfter, this.endedBefore, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -372,6 +374,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional approverId = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -386,8 +390,6 @@ public static final class Builder { private Optional endedBefore = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -420,6 +422,7 @@ public static final class Builder { private Builder() {} public Builder from(TimeOffListRequest other) { + expand(other.getExpand()); approverId(other.getApproverId()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); @@ -427,7 +430,6 @@ public Builder from(TimeOffListRequest other) { employeeId(other.getEmployeeId()); endedAfter(other.getEndedAfter()); endedBefore(other.getEndedBefore()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -444,6 +446,22 @@ public Builder from(TimeOffListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(TimeOffListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "approver_id", nulls = Nulls.SKIP) public Builder approverId(Optional approverId) { this.approverId = approverId; @@ -521,17 +539,6 @@ public Builder endedBefore(OffsetDateTime endedBefore) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(TimeOffListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -677,6 +684,7 @@ public Builder status(TimeOffListRequestStatus status) { public TimeOffListRequest build() { return new TimeOffListRequest( + expand, approverId, createdAfter, createdBefore, @@ -684,7 +692,6 @@ public TimeOffListRequest build() { employeeId, endedAfter, endedBefore, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/hris/timeoff/requests/TimeOffRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/timeoff/requests/TimeOffRetrieveRequest.java index 59bfb6a1e..09f668d84 100644 --- a/src/main/java/com/merge/api/resources/hris/timeoff/requests/TimeOffRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/timeoff/requests/TimeOffRetrieveRequest.java @@ -12,10 +12,12 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.hris.timeoff.types.TimeOffRetrieveRequestExpand; +import com.merge.api.resources.hris.timeoff.types.TimeOffRetrieveRequestExpandItem; import com.merge.api.resources.hris.timeoff.types.TimeOffRetrieveRequestRemoteFields; import com.merge.api.resources.hris.timeoff.types.TimeOffRetrieveRequestShowEnumOrigins; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,10 +25,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TimeOffRetrieveRequest.Builder.class) public final class TimeOffRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -34,13 +38,15 @@ public final class TimeOffRetrieveRequest { private final Map additionalProperties; private TimeOffRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -50,7 +56,7 @@ private TimeOffRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -62,6 +68,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -92,13 +106,15 @@ public Map getAdditionalProperties() { private boolean equalTo(TimeOffRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -112,10 +128,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -128,22 +146,28 @@ private Builder() {} public Builder from(TimeOffRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(TimeOffRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(TimeOffRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -155,6 +179,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -179,7 +214,7 @@ public Builder showEnumOrigins(TimeOffRetrieveRequestShowEnumOrigins showEnumOri public TimeOffRetrieveRequest build() { return new TimeOffRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffListRequestExpand.java b/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffListRequestExpand.java deleted file mode 100644 index f3e70395d..000000000 --- a/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.timeoff.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TimeOffListRequestExpand { - APPROVER("approver"), - - EMPLOYEE("employee"), - - EMPLOYEE_APPROVER("employee,approver"); - - private final String value; - - TimeOffListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffListRequestExpandItem.java b/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffListRequestExpandItem.java new file mode 100644 index 000000000..2c4eb33d0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timeoff.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TimeOffListRequestExpandItem { + APPROVER("approver"), + + EMPLOYEE("employee"); + + private final String value; + + TimeOffListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffRetrieveRequestExpand.java deleted file mode 100644 index 0cabcc32f..000000000 --- a/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffRetrieveRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.timeoff.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TimeOffRetrieveRequestExpand { - APPROVER("approver"), - - EMPLOYEE("employee"), - - EMPLOYEE_APPROVER("employee,approver"); - - private final String value; - - TimeOffRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffRetrieveRequestExpandItem.java new file mode 100644 index 000000000..4aea8bcd3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timeoff/types/TimeOffRetrieveRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timeoff.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TimeOffRetrieveRequestExpandItem { + APPROVER("approver"), + + EMPLOYEE("employee"); + + private final String value; + + TimeOffRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timeoffbalances/AsyncRawTimeOffBalancesClient.java b/src/main/java/com/merge/api/resources/hris/timeoffbalances/AsyncRawTimeOffBalancesClient.java new file mode 100644 index 000000000..5cf082bf4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timeoffbalances/AsyncRawTimeOffBalancesClient.java @@ -0,0 +1,265 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timeoffbalances; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.timeoffbalances.requests.TimeOffBalancesListRequest; +import com.merge.api.resources.hris.timeoffbalances.requests.TimeOffBalancesRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedTimeOffBalanceList; +import com.merge.api.resources.hris.types.TimeOffBalance; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTimeOffBalancesClient { + protected final ClientOptions clientOptions; + + public AsyncRawTimeOffBalancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of TimeOffBalance objects. + */ + public CompletableFuture> list() { + return list(TimeOffBalancesListRequest.builder().build()); + } + + /** + * Returns a list of TimeOffBalance objects. + */ + public CompletableFuture> list( + TimeOffBalancesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of TimeOffBalance objects. + */ + public CompletableFuture> list( + TimeOffBalancesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off-balances"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPolicyType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "policy_type", request.getPolicyType().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedTimeOffBalanceList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a TimeOffBalance object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TimeOffBalancesRetrieveRequest.builder().build()); + } + + /** + * Returns a TimeOffBalance object with the given id. + */ + public CompletableFuture> retrieve( + String id, TimeOffBalancesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a TimeOffBalance object with the given id. + */ + public CompletableFuture> retrieve( + String id, TimeOffBalancesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off-balances") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimeOffBalance.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timeoffbalances/AsyncTimeOffBalancesClient.java b/src/main/java/com/merge/api/resources/hris/timeoffbalances/AsyncTimeOffBalancesClient.java new file mode 100644 index 000000000..e16aab3ef --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timeoffbalances/AsyncTimeOffBalancesClient.java @@ -0,0 +1,74 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timeoffbalances; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.timeoffbalances.requests.TimeOffBalancesListRequest; +import com.merge.api.resources.hris.timeoffbalances.requests.TimeOffBalancesRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedTimeOffBalanceList; +import com.merge.api.resources.hris.types.TimeOffBalance; +import java.util.concurrent.CompletableFuture; + +public class AsyncTimeOffBalancesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTimeOffBalancesClient rawClient; + + public AsyncTimeOffBalancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTimeOffBalancesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTimeOffBalancesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of TimeOffBalance objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of TimeOffBalance objects. + */ + public CompletableFuture list(TimeOffBalancesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of TimeOffBalance objects. + */ + public CompletableFuture list( + TimeOffBalancesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a TimeOffBalance object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a TimeOffBalance object with the given id. + */ + public CompletableFuture retrieve(String id, TimeOffBalancesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a TimeOffBalance object with the given id. + */ + public CompletableFuture retrieve( + String id, TimeOffBalancesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timeoffbalances/RawTimeOffBalancesClient.java b/src/main/java/com/merge/api/resources/hris/timeoffbalances/RawTimeOffBalancesClient.java new file mode 100644 index 000000000..6e5eb9315 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timeoffbalances/RawTimeOffBalancesClient.java @@ -0,0 +1,231 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timeoffbalances; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.timeoffbalances.requests.TimeOffBalancesListRequest; +import com.merge.api.resources.hris.timeoffbalances.requests.TimeOffBalancesRetrieveRequest; +import com.merge.api.resources.hris.types.PaginatedTimeOffBalanceList; +import com.merge.api.resources.hris.types.TimeOffBalance; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTimeOffBalancesClient { + protected final ClientOptions clientOptions; + + public RawTimeOffBalancesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of TimeOffBalance objects. + */ + public MergeApiHttpResponse list() { + return list(TimeOffBalancesListRequest.builder().build()); + } + + /** + * Returns a list of TimeOffBalance objects. + */ + public MergeApiHttpResponse list(TimeOffBalancesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of TimeOffBalance objects. + */ + public MergeApiHttpResponse list( + TimeOffBalancesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off-balances"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getPolicyType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "policy_type", request.getPolicyType().get().toString(), false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTimeOffBalanceList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a TimeOffBalance object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TimeOffBalancesRetrieveRequest.builder().build()); + } + + /** + * Returns a TimeOffBalance object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TimeOffBalancesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a TimeOffBalance object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, TimeOffBalancesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/time-off-balances") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimeOffBalance.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timeoffbalances/TimeOffBalancesClient.java b/src/main/java/com/merge/api/resources/hris/timeoffbalances/TimeOffBalancesClient.java index 7b72a90c3..86a98624c 100644 --- a/src/main/java/com/merge/api/resources/hris/timeoffbalances/TimeOffBalancesClient.java +++ b/src/main/java/com/merge/api/resources/hris/timeoffbalances/TimeOffBalancesClient.java @@ -3,191 +3,69 @@ */ package com.merge.api.resources.hris.timeoffbalances; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.timeoffbalances.requests.TimeOffBalancesListRequest; import com.merge.api.resources.hris.timeoffbalances.requests.TimeOffBalancesRetrieveRequest; import com.merge.api.resources.hris.types.PaginatedTimeOffBalanceList; import com.merge.api.resources.hris.types.TimeOffBalance; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TimeOffBalancesClient { protected final ClientOptions clientOptions; + private final RawTimeOffBalancesClient rawClient; + public TimeOffBalancesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTimeOffBalancesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTimeOffBalancesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of TimeOffBalance objects. */ public PaginatedTimeOffBalanceList list() { - return list(TimeOffBalancesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of TimeOffBalance objects. */ public PaginatedTimeOffBalanceList list(TimeOffBalancesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of TimeOffBalance objects. */ public PaginatedTimeOffBalanceList list(TimeOffBalancesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/time-off-balances"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmployeeId().isPresent()) { - httpUrl.addQueryParameter("employee_id", request.getEmployeeId().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getPolicyType().isPresent()) { - httpUrl.addQueryParameter( - "policy_type", request.getPolicyType().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTimeOffBalanceList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a TimeOffBalance object with the given id. */ public TimeOffBalance retrieve(String id) { - return retrieve(id, TimeOffBalancesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a TimeOffBalance object with the given id. */ public TimeOffBalance retrieve(String id, TimeOffBalancesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a TimeOffBalance object with the given id. */ public TimeOffBalance retrieve(String id, TimeOffBalancesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/time-off-balances") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimeOffBalance.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/timeoffbalances/requests/TimeOffBalancesListRequest.java b/src/main/java/com/merge/api/resources/hris/timeoffbalances/requests/TimeOffBalancesListRequest.java index 2ca29297d..12f6432a6 100644 --- a/src/main/java/com/merge/api/resources/hris/timeoffbalances/requests/TimeOffBalancesListRequest.java +++ b/src/main/java/com/merge/api/resources/hris/timeoffbalances/requests/TimeOffBalancesListRequest.java @@ -14,7 +14,9 @@ import com.merge.api.core.ObjectMappers; import com.merge.api.resources.hris.timeoffbalances.types.TimeOffBalancesListRequestPolicyType; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TimeOffBalancesListRequest.Builder.class) public final class TimeOffBalancesListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; @@ -30,8 +34,6 @@ public final class TimeOffBalancesListRequest { private final Optional employeeId; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -55,11 +57,11 @@ public final class TimeOffBalancesListRequest { private final Map additionalProperties; private TimeOffBalancesListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, Optional employeeId, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -71,11 +73,11 @@ private TimeOffBalancesListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.employeeId = employeeId; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -89,6 +91,14 @@ private TimeOffBalancesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -121,14 +131,6 @@ public Optional getEmployeeId() { return employeeId; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -229,11 +231,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(TimeOffBalancesListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && employeeId.equals(other.employeeId) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -249,11 +251,11 @@ private boolean equalTo(TimeOffBalancesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, this.employeeId, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -277,6 +279,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); @@ -285,8 +289,6 @@ public static final class Builder { private Optional employeeId = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -313,11 +315,11 @@ public static final class Builder { private Builder() {} public Builder from(TimeOffBalancesListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); employeeId(other.getEmployeeId()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -331,6 +333,22 @@ public Builder from(TimeOffBalancesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -375,17 +393,6 @@ public Builder employeeId(String employeeId) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -498,11 +505,11 @@ public Builder showEnumOrigins(String showEnumOrigins) { public TimeOffBalancesListRequest build() { return new TimeOffBalancesListRequest( + expand, createdAfter, createdBefore, cursor, employeeId, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/hris/timeoffbalances/requests/TimeOffBalancesRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/timeoffbalances/requests/TimeOffBalancesRetrieveRequest.java index c683548d2..995a3922a 100644 --- a/src/main/java/com/merge/api/resources/hris/timeoffbalances/requests/TimeOffBalancesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/timeoffbalances/requests/TimeOffBalancesRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,10 +22,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TimeOffBalancesRetrieveRequest.Builder.class) public final class TimeOffBalancesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -31,13 +35,15 @@ public final class TimeOffBalancesRetrieveRequest { private final Map additionalProperties; private TimeOffBalancesRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -47,7 +53,7 @@ private TimeOffBalancesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -59,6 +65,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -89,13 +103,15 @@ public Map getAdditionalProperties() { private boolean equalTo(TimeOffBalancesRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -109,10 +125,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -125,22 +143,28 @@ private Builder() {} public Builder from(TimeOffBalancesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -152,6 +176,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -176,7 +211,7 @@ public Builder showEnumOrigins(String showEnumOrigins) { public TimeOffBalancesRetrieveRequest build() { return new TimeOffBalancesRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/timesheetentries/AsyncRawTimesheetEntriesClient.java b/src/main/java/com/merge/api/resources/hris/timesheetentries/AsyncRawTimesheetEntriesClient.java new file mode 100644 index 000000000..fbadeef3c --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timesheetentries/AsyncRawTimesheetEntriesClient.java @@ -0,0 +1,405 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timesheetentries; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntriesListRequest; +import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntriesRetrieveRequest; +import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntryEndpointRequest; +import com.merge.api.resources.hris.types.MetaResponse; +import com.merge.api.resources.hris.types.PaginatedTimesheetEntryList; +import com.merge.api.resources.hris.types.TimesheetEntry; +import com.merge.api.resources.hris.types.TimesheetEntryResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTimesheetEntriesClient { + protected final ClientOptions clientOptions; + + public AsyncRawTimesheetEntriesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of TimesheetEntry objects. + */ + public CompletableFuture> list() { + return list(TimesheetEntriesListRequest.builder().build()); + } + + /** + * Returns a list of TimesheetEntry objects. + */ + public CompletableFuture> list( + TimesheetEntriesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of TimesheetEntry objects. + */ + public CompletableFuture> list( + TimesheetEntriesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/timesheet-entries"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getEndedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_after", request.getEndedAfter().get().toString(), false); + } + if (request.getEndedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_before", request.getEndedBefore().get().toString(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOrderBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order_by", request.getOrderBy().get().toString(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedTimesheetEntryList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a TimesheetEntry object with the given values. + */ + public CompletableFuture> create( + TimesheetEntryEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a TimesheetEntry object with the given values. + */ + public CompletableFuture> create( + TimesheetEntryEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/timesheet-entries"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), TimesheetEntryResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a TimesheetEntry object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TimesheetEntriesRetrieveRequest.builder().build()); + } + + /** + * Returns a TimesheetEntry object with the given id. + */ + public CompletableFuture> retrieve( + String id, TimesheetEntriesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a TimesheetEntry object with the given id. + */ + public CompletableFuture> retrieve( + String id, TimesheetEntriesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/timesheet-entries") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimesheetEntry.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for TimesheetEntry POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for TimesheetEntry POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/timesheet-entries/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timesheetentries/AsyncTimesheetEntriesClient.java b/src/main/java/com/merge/api/resources/hris/timesheetentries/AsyncTimesheetEntriesClient.java new file mode 100644 index 000000000..5e3f6b0d7 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timesheetentries/AsyncTimesheetEntriesClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timesheetentries; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntriesListRequest; +import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntriesRetrieveRequest; +import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntryEndpointRequest; +import com.merge.api.resources.hris.types.MetaResponse; +import com.merge.api.resources.hris.types.PaginatedTimesheetEntryList; +import com.merge.api.resources.hris.types.TimesheetEntry; +import com.merge.api.resources.hris.types.TimesheetEntryResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncTimesheetEntriesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTimesheetEntriesClient rawClient; + + public AsyncTimesheetEntriesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTimesheetEntriesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTimesheetEntriesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of TimesheetEntry objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of TimesheetEntry objects. + */ + public CompletableFuture list(TimesheetEntriesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of TimesheetEntry objects. + */ + public CompletableFuture list( + TimesheetEntriesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a TimesheetEntry object with the given values. + */ + public CompletableFuture create(TimesheetEntryEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a TimesheetEntry object with the given values. + */ + public CompletableFuture create( + TimesheetEntryEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a TimesheetEntry object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a TimesheetEntry object with the given id. + */ + public CompletableFuture retrieve(String id, TimesheetEntriesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a TimesheetEntry object with the given id. + */ + public CompletableFuture retrieve( + String id, TimesheetEntriesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for TimesheetEntry POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for TimesheetEntry POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timesheetentries/RawTimesheetEntriesClient.java b/src/main/java/com/merge/api/resources/hris/timesheetentries/RawTimesheetEntriesClient.java new file mode 100644 index 000000000..97987dba4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/timesheetentries/RawTimesheetEntriesClient.java @@ -0,0 +1,342 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.timesheetentries; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntriesListRequest; +import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntriesRetrieveRequest; +import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntryEndpointRequest; +import com.merge.api.resources.hris.types.MetaResponse; +import com.merge.api.resources.hris.types.PaginatedTimesheetEntryList; +import com.merge.api.resources.hris.types.TimesheetEntry; +import com.merge.api.resources.hris.types.TimesheetEntryResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTimesheetEntriesClient { + protected final ClientOptions clientOptions; + + public RawTimesheetEntriesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of TimesheetEntry objects. + */ + public MergeApiHttpResponse list() { + return list(TimesheetEntriesListRequest.builder().build()); + } + + /** + * Returns a list of TimesheetEntry objects. + */ + public MergeApiHttpResponse list(TimesheetEntriesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of TimesheetEntry objects. + */ + public MergeApiHttpResponse list( + TimesheetEntriesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/timesheet-entries"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmployeeId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "employee_id", request.getEmployeeId().get(), false); + } + if (request.getEndedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_after", request.getEndedAfter().get().toString(), false); + } + if (request.getEndedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ended_before", request.getEndedBefore().get().toString(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getOrderBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "order_by", request.getOrderBy().get().toString(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getStartedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_after", request.getStartedAfter().get().toString(), false); + } + if (request.getStartedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "started_before", request.getStartedBefore().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTimesheetEntryList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a TimesheetEntry object with the given values. + */ + public MergeApiHttpResponse create(TimesheetEntryEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a TimesheetEntry object with the given values. + */ + public MergeApiHttpResponse create( + TimesheetEntryEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/timesheet-entries"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimesheetEntryResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a TimesheetEntry object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TimesheetEntriesRetrieveRequest.builder().build()); + } + + /** + * Returns a TimesheetEntry object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TimesheetEntriesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a TimesheetEntry object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, TimesheetEntriesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/timesheet-entries") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimesheetEntry.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for TimesheetEntry POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for TimesheetEntry POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/timesheet-entries/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/timesheetentries/TimesheetEntriesClient.java b/src/main/java/com/merge/api/resources/hris/timesheetentries/TimesheetEntriesClient.java index 2c0a69e9b..fc51a9892 100644 --- a/src/main/java/com/merge/api/resources/hris/timesheetentries/TimesheetEntriesClient.java +++ b/src/main/java/com/merge/api/resources/hris/timesheetentries/TimesheetEntriesClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.hris.timesheetentries; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntriesListRequest; import com.merge.api.resources.hris.timesheetentries.requests.TimesheetEntriesRetrieveRequest; @@ -16,283 +12,91 @@ import com.merge.api.resources.hris.types.PaginatedTimesheetEntryList; import com.merge.api.resources.hris.types.TimesheetEntry; import com.merge.api.resources.hris.types.TimesheetEntryResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TimesheetEntriesClient { protected final ClientOptions clientOptions; + private final RawTimesheetEntriesClient rawClient; + public TimesheetEntriesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTimesheetEntriesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTimesheetEntriesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of TimesheetEntry objects. */ public PaginatedTimesheetEntryList list() { - return list(TimesheetEntriesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of TimesheetEntry objects. */ public PaginatedTimesheetEntryList list(TimesheetEntriesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of TimesheetEntry objects. */ public PaginatedTimesheetEntryList list(TimesheetEntriesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/timesheet-entries"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmployeeId().isPresent()) { - httpUrl.addQueryParameter("employee_id", request.getEmployeeId().get()); - } - if (request.getEndedAfter().isPresent()) { - httpUrl.addQueryParameter( - "ended_after", request.getEndedAfter().get().toString()); - } - if (request.getEndedBefore().isPresent()) { - httpUrl.addQueryParameter( - "ended_before", request.getEndedBefore().get().toString()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getOrderBy().isPresent()) { - httpUrl.addQueryParameter("order_by", request.getOrderBy().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getStartedAfter().isPresent()) { - httpUrl.addQueryParameter( - "started_after", request.getStartedAfter().get().toString()); - } - if (request.getStartedBefore().isPresent()) { - httpUrl.addQueryParameter( - "started_before", request.getStartedBefore().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTimesheetEntryList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a TimesheetEntry object with the given values. */ public TimesheetEntryResponse create(TimesheetEntryEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a TimesheetEntry object with the given values. */ public TimesheetEntryResponse create(TimesheetEntryEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/timesheet-entries"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimesheetEntryResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a TimesheetEntry object with the given id. */ public TimesheetEntry retrieve(String id) { - return retrieve(id, TimesheetEntriesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a TimesheetEntry object with the given id. */ public TimesheetEntry retrieve(String id, TimesheetEntriesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a TimesheetEntry object with the given id. */ public TimesheetEntry retrieve(String id, TimesheetEntriesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/timesheet-entries") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TimesheetEntry.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for TimesheetEntry POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for TimesheetEntry POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/timesheet-entries/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/hris/timesheetentries/requests/TimesheetEntriesListRequest.java b/src/main/java/com/merge/api/resources/hris/timesheetentries/requests/TimesheetEntriesListRequest.java index add966ea4..e83cd63f2 100644 --- a/src/main/java/com/merge/api/resources/hris/timesheetentries/requests/TimesheetEntriesListRequest.java +++ b/src/main/java/com/merge/api/resources/hris/timesheetentries/requests/TimesheetEntriesListRequest.java @@ -14,7 +14,9 @@ import com.merge.api.core.ObjectMappers; import com.merge.api.resources.hris.timesheetentries.types.TimesheetEntriesListRequestOrderBy; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TimesheetEntriesListRequest.Builder.class) public final class TimesheetEntriesListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; @@ -34,8 +38,6 @@ public final class TimesheetEntriesListRequest { private final Optional endedBefore; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -59,13 +61,13 @@ public final class TimesheetEntriesListRequest { private final Map additionalProperties; private TimesheetEntriesListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, Optional employeeId, Optional endedAfter, Optional endedBefore, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -77,13 +79,13 @@ private TimesheetEntriesListRequest( Optional startedAfter, Optional startedBefore, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.employeeId = employeeId; this.endedAfter = endedAfter; this.endedBefore = endedBefore; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -97,6 +99,14 @@ private TimesheetEntriesListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -145,14 +155,6 @@ public Optional getEndedBefore() { return endedBefore; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -245,13 +247,13 @@ public Map getAdditionalProperties() { } private boolean equalTo(TimesheetEntriesListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && employeeId.equals(other.employeeId) && endedAfter.equals(other.endedAfter) && endedBefore.equals(other.endedBefore) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -267,13 +269,13 @@ private boolean equalTo(TimesheetEntriesListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, this.employeeId, this.endedAfter, this.endedBefore, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -297,6 +299,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); @@ -309,8 +313,6 @@ public static final class Builder { private Optional endedBefore = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -337,13 +339,13 @@ public static final class Builder { private Builder() {} public Builder from(TimesheetEntriesListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); employeeId(other.getEmployeeId()); endedAfter(other.getEndedAfter()); endedBefore(other.getEndedBefore()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -357,6 +359,22 @@ public Builder from(TimesheetEntriesListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -423,17 +441,6 @@ public Builder endedBefore(OffsetDateTime endedBefore) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -546,13 +553,13 @@ public Builder startedBefore(OffsetDateTime startedBefore) { public TimesheetEntriesListRequest build() { return new TimesheetEntriesListRequest( + expand, createdAfter, createdBefore, cursor, employeeId, endedAfter, endedBefore, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/hris/timesheetentries/requests/TimesheetEntriesRetrieveRequest.java b/src/main/java/com/merge/api/resources/hris/timesheetentries/requests/TimesheetEntriesRetrieveRequest.java index 81deb020b..3634f0cf7 100644 --- a/src/main/java/com/merge/api/resources/hris/timesheetentries/requests/TimesheetEntriesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/hris/timesheetentries/requests/TimesheetEntriesRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TimesheetEntriesRetrieveRequest.Builder.class) public final class TimesheetEntriesRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private TimesheetEntriesRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private TimesheetEntriesRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(TimesheetEntriesRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(TimesheetEntriesRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,20 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public TimesheetEntriesRetrieveRequest build() { - return new TimesheetEntriesRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new TimesheetEntriesRetrieveRequest( + expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/types/AccountToken.java b/src/main/java/com/merge/api/resources/hris/types/AccountToken.java index cc5fe635f..dade07b65 100644 --- a/src/main/java/com/merge/api/resources/hris/types/AccountToken.java +++ b/src/main/java/com/merge/api/resources/hris/types/AccountToken.java @@ -23,12 +23,15 @@ public final class AccountToken { private final AccountIntegration integration; + private final String id; + private final Map additionalProperties; private AccountToken( - String accountToken, AccountIntegration integration, Map additionalProperties) { + String accountToken, AccountIntegration integration, String id, Map additionalProperties) { this.accountToken = accountToken; this.integration = integration; + this.id = id; this.additionalProperties = additionalProperties; } @@ -42,6 +45,11 @@ public AccountIntegration getIntegration() { return integration; } + @JsonProperty("id") + public String getId() { + return id; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -54,12 +62,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(AccountToken other) { - return accountToken.equals(other.accountToken) && integration.equals(other.integration); + return accountToken.equals(other.accountToken) && integration.equals(other.integration) && id.equals(other.id); } @java.lang.Override public int hashCode() { - return Objects.hash(this.accountToken, this.integration); + return Objects.hash(this.accountToken, this.integration, this.id); } @java.lang.Override @@ -78,7 +86,11 @@ public interface AccountTokenStage { } public interface IntegrationStage { - _FinalStage integration(@NotNull AccountIntegration integration); + IdStage integration(@NotNull AccountIntegration integration); + } + + public interface IdStage { + _FinalStage id(@NotNull String id); } public interface _FinalStage { @@ -86,11 +98,13 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AccountTokenStage, IntegrationStage, _FinalStage { + public static final class Builder implements AccountTokenStage, IntegrationStage, IdStage, _FinalStage { private String accountToken; private AccountIntegration integration; + private String id; + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -100,6 +114,7 @@ private Builder() {} public Builder from(AccountToken other) { accountToken(other.getAccountToken()); integration(other.getIntegration()); + id(other.getId()); return this; } @@ -112,14 +127,21 @@ public IntegrationStage accountToken(@NotNull String accountToken) { @java.lang.Override @JsonSetter("integration") - public _FinalStage integration(@NotNull AccountIntegration integration) { + public IdStage integration(@NotNull AccountIntegration integration) { this.integration = integration; return this; } + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = id; + return this; + } + @java.lang.Override public AccountToken build() { - return new AccountToken(accountToken, integration, additionalProperties); + return new AccountToken(accountToken, integration, id, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/hris/types/AuditLogEvent.java b/src/main/java/com/merge/api/resources/hris/types/AuditLogEvent.java index 5ed7afabc..2e6d61348 100644 --- a/src/main/java/com/merge/api/resources/hris/types/AuditLogEvent.java +++ b/src/main/java/com/merge/api/resources/hris/types/AuditLogEvent.java @@ -28,11 +28,11 @@ public final class AuditLogEvent { private final Optional userEmail; - private final AuditLogEventRole role; + private final RoleEnum role; private final String ipAddress; - private final AuditLogEventEventType eventType; + private final EventTypeEnum eventType; private final String eventDescription; @@ -44,9 +44,9 @@ private AuditLogEvent( Optional id, Optional userName, Optional userEmail, - AuditLogEventRole role, + RoleEnum role, String ipAddress, - AuditLogEventEventType eventType, + EventTypeEnum eventType, String eventDescription, Optional createdAt, Map additionalProperties) { @@ -94,7 +94,7 @@ public Optional getUserEmail() { *
    */ @JsonProperty("role") - public AuditLogEventRole getRole() { + public RoleEnum getRole() { return role; } @@ -115,6 +115,7 @@ public String getIpAddress() { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -150,7 +151,7 @@ public String getIpAddress() { * */ @JsonProperty("event_type") - public AuditLogEventEventType getEventType() { + public EventTypeEnum getEventType() { return eventType; } @@ -209,7 +210,7 @@ public static RoleStage builder() { } public interface RoleStage { - IpAddressStage role(@NotNull AuditLogEventRole role); + IpAddressStage role(@NotNull RoleEnum role); Builder from(AuditLogEvent other); } @@ -219,7 +220,7 @@ public interface IpAddressStage { } public interface EventTypeStage { - EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType); + EventDescriptionStage eventType(@NotNull EventTypeEnum eventType); } public interface EventDescriptionStage { @@ -249,11 +250,11 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements RoleStage, IpAddressStage, EventTypeStage, EventDescriptionStage, _FinalStage { - private AuditLogEventRole role; + private RoleEnum role; private String ipAddress; - private AuditLogEventEventType eventType; + private EventTypeEnum eventType; private String eventDescription; @@ -297,7 +298,7 @@ public Builder from(AuditLogEvent other) { */ @java.lang.Override @JsonSetter("role") - public IpAddressStage role(@NotNull AuditLogEventRole role) { + public IpAddressStage role(@NotNull RoleEnum role) { this.role = role; return this; } @@ -321,6 +322,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -358,7 +360,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { */ @java.lang.Override @JsonSetter("event_type") - public EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType) { + public EventDescriptionStage eventType(@NotNull EventTypeEnum eventType) { this.eventType = eventType; return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/AuditLogEventEventType.java b/src/main/java/com/merge/api/resources/hris/types/AuditLogEventEventType.java deleted file mode 100644 index 1d8c6e12b..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/AuditLogEventEventType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventEventType.Deserializer.class) -public final class AuditLogEventEventType { - private final Object value; - - private final int type; - - private AuditLogEventEventType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EventTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventEventType && equalTo((AuditLogEventEventType) other); - } - - private boolean equalTo(AuditLogEventEventType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventEventType of(EventTypeEnum value) { - return new AuditLogEventEventType(value, 0); - } - - public static AuditLogEventEventType of(String value) { - return new AuditLogEventEventType(value, 1); - } - - public interface Visitor { - T visit(EventTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventEventType.class); - } - - @java.lang.Override - public AuditLogEventEventType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EventTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/AuditLogEventRole.java b/src/main/java/com/merge/api/resources/hris/types/AuditLogEventRole.java deleted file mode 100644 index 32152bd0d..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/AuditLogEventRole.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventRole.Deserializer.class) -public final class AuditLogEventRole { - private final Object value; - - private final int type; - - private AuditLogEventRole(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RoleEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventRole && equalTo((AuditLogEventRole) other); - } - - private boolean equalTo(AuditLogEventRole other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventRole of(RoleEnum value) { - return new AuditLogEventRole(value, 0); - } - - public static AuditLogEventRole of(String value) { - return new AuditLogEventRole(value, 1); - } - - public interface Visitor { - T visit(RoleEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventRole.class); - } - - @java.lang.Override - public AuditLogEventRole deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RoleEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/BankInfo.java b/src/main/java/com/merge/api/resources/hris/types/BankInfo.java index 85d3963ec..0a1c337cf 100644 --- a/src/main/java/com/merge/api/resources/hris/types/BankInfo.java +++ b/src/main/java/com/merge/api/resources/hris/types/BankInfo.java @@ -39,7 +39,7 @@ public final class BankInfo { private final Optional bankName; - private final Optional accountType; + private final Optional accountType; private final Optional remoteCreatedAt; @@ -60,7 +60,7 @@ private BankInfo( Optional accountNumber, Optional routingNumber, Optional bankName, - Optional accountType, + Optional accountType, Optional remoteCreatedAt, Optional remoteWasDeleted, Optional> fieldMappings, @@ -151,7 +151,7 @@ public Optional getBankName() { * */ @JsonProperty("account_type") - public Optional getAccountType() { + public Optional getAccountType() { return accountType; } @@ -253,7 +253,7 @@ public static final class Builder { private Optional bankName = Optional.empty(); - private Optional accountType = Optional.empty(); + private Optional accountType = Optional.empty(); private Optional remoteCreatedAt = Optional.empty(); @@ -374,12 +374,12 @@ public Builder bankName(String bankName) { } @JsonSetter(value = "account_type", nulls = Nulls.SKIP) - public Builder accountType(Optional accountType) { + public Builder accountType(Optional accountType) { this.accountType = accountType; return this; } - public Builder accountType(BankInfoAccountType accountType) { + public Builder accountType(AccountTypeEnum accountType) { this.accountType = Optional.ofNullable(accountType); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/BankInfoAccountType.java b/src/main/java/com/merge/api/resources/hris/types/BankInfoAccountType.java deleted file mode 100644 index 8fa7c78eb..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/BankInfoAccountType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = BankInfoAccountType.Deserializer.class) -public final class BankInfoAccountType { - private final Object value; - - private final int type; - - private BankInfoAccountType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AccountTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BankInfoAccountType && equalTo((BankInfoAccountType) other); - } - - private boolean equalTo(BankInfoAccountType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static BankInfoAccountType of(AccountTypeEnum value) { - return new BankInfoAccountType(value, 0); - } - - public static BankInfoAccountType of(String value) { - return new BankInfoAccountType(value, 1); - } - - public interface Visitor { - T visit(AccountTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(BankInfoAccountType.class); - } - - @java.lang.Override - public BankInfoAccountType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AccountTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/BankInfoEmployee.java b/src/main/java/com/merge/api/resources/hris/types/BankInfoEmployee.java index 2fa1119b5..4b5b981eb 100644 --- a/src/main/java/com/merge/api/resources/hris/types/BankInfoEmployee.java +++ b/src/main/java/com/merge/api/resources/hris/types/BankInfoEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public BankInfoEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public BankInfoEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/BenefitEmployee.java b/src/main/java/com/merge/api/resources/hris/types/BenefitEmployee.java index 9b0c4a1f7..e0a705974 100644 --- a/src/main/java/com/merge/api/resources/hris/types/BenefitEmployee.java +++ b/src/main/java/com/merge/api/resources/hris/types/BenefitEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public BenefitEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public BenefitEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/Dependent.java b/src/main/java/com/merge/api/resources/hris/types/Dependent.java index 3145491f7..fac01b3cc 100644 --- a/src/main/java/com/merge/api/resources/hris/types/Dependent.java +++ b/src/main/java/com/merge/api/resources/hris/types/Dependent.java @@ -37,13 +37,13 @@ public final class Dependent { private final Optional lastName; - private final Optional relationship; + private final Optional relationship; private final Optional employee; private final Optional dateOfBirth; - private final Optional gender; + private final Optional gender; private final Optional phoneNumber; @@ -69,10 +69,10 @@ private Dependent( Optional firstName, Optional middleName, Optional lastName, - Optional relationship, + Optional relationship, Optional employee, Optional dateOfBirth, - Optional gender, + Optional gender, Optional phoneNumber, Optional homeLocation, Optional isStudent, @@ -164,7 +164,7 @@ public Optional getLastName() { * */ @JsonProperty("relationship") - public Optional getRelationship() { + public Optional getRelationship() { return relationship; } @@ -195,7 +195,7 @@ public Optional getDateOfBirth() { * */ @JsonProperty("gender") - public Optional getGender() { + public Optional getGender() { return gender; } @@ -329,13 +329,13 @@ public static final class Builder { private Optional lastName = Optional.empty(); - private Optional relationship = Optional.empty(); + private Optional relationship = Optional.empty(); private Optional employee = Optional.empty(); private Optional dateOfBirth = Optional.empty(); - private Optional gender = Optional.empty(); + private Optional gender = Optional.empty(); private Optional phoneNumber = Optional.empty(); @@ -456,12 +456,12 @@ public Builder lastName(String lastName) { } @JsonSetter(value = "relationship", nulls = Nulls.SKIP) - public Builder relationship(Optional relationship) { + public Builder relationship(Optional relationship) { this.relationship = relationship; return this; } - public Builder relationship(DependentRelationship relationship) { + public Builder relationship(RelationshipEnum relationship) { this.relationship = Optional.ofNullable(relationship); return this; } @@ -489,12 +489,12 @@ public Builder dateOfBirth(OffsetDateTime dateOfBirth) { } @JsonSetter(value = "gender", nulls = Nulls.SKIP) - public Builder gender(Optional gender) { + public Builder gender(Optional gender) { this.gender = gender; return this; } - public Builder gender(DependentGender gender) { + public Builder gender(GenderEnum gender) { this.gender = Optional.ofNullable(gender); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/DependentGender.java b/src/main/java/com/merge/api/resources/hris/types/DependentGender.java deleted file mode 100644 index c6d1daf52..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/DependentGender.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = DependentGender.Deserializer.class) -public final class DependentGender { - private final Object value; - - private final int type; - - private DependentGender(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((GenderEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DependentGender && equalTo((DependentGender) other); - } - - private boolean equalTo(DependentGender other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static DependentGender of(GenderEnum value) { - return new DependentGender(value, 0); - } - - public static DependentGender of(String value) { - return new DependentGender(value, 1); - } - - public interface Visitor { - T visit(GenderEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(DependentGender.class); - } - - @java.lang.Override - public DependentGender deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, GenderEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/DependentRelationship.java b/src/main/java/com/merge/api/resources/hris/types/DependentRelationship.java deleted file mode 100644 index b19b696ea..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/DependentRelationship.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = DependentRelationship.Deserializer.class) -public final class DependentRelationship { - private final Object value; - - private final int type; - - private DependentRelationship(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RelationshipEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DependentRelationship && equalTo((DependentRelationship) other); - } - - private boolean equalTo(DependentRelationship other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static DependentRelationship of(RelationshipEnum value) { - return new DependentRelationship(value, 0); - } - - public static DependentRelationship of(String value) { - return new DependentRelationship(value, 1); - } - - public interface Visitor { - T visit(RelationshipEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(DependentRelationship.class); - } - - @java.lang.Override - public DependentRelationship deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RelationshipEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/Earning.java b/src/main/java/com/merge/api/resources/hris/types/Earning.java index 6958d177b..89e800526 100644 --- a/src/main/java/com/merge/api/resources/hris/types/Earning.java +++ b/src/main/java/com/merge/api/resources/hris/types/Earning.java @@ -35,7 +35,7 @@ public final class Earning { private final Optional amount; - private final Optional type; + private final Optional type; private final Optional remoteWasDeleted; @@ -52,7 +52,7 @@ private Earning( Optional modifiedAt, Optional employeePayrollRun, Optional amount, - Optional type, + Optional type, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -122,7 +122,7 @@ public Optional getAmount() { * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } @@ -206,7 +206,7 @@ public static final class Builder { private Optional amount = Optional.empty(); - private Optional type = Optional.empty(); + private Optional type = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -300,12 +300,12 @@ public Builder amount(Double amount) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(EarningType type) { + public Builder type(EarningTypeEnum type) { this.type = Optional.ofNullable(type); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/EarningType.java b/src/main/java/com/merge/api/resources/hris/types/EarningType.java deleted file mode 100644 index 94d38ea34..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EarningType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EarningType.Deserializer.class) -public final class EarningType { - private final Object value; - - private final int type; - - private EarningType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EarningTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EarningType && equalTo((EarningType) other); - } - - private boolean equalTo(EarningType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EarningType of(EarningTypeEnum value) { - return new EarningType(value, 0); - } - - public static EarningType of(String value) { - return new EarningType(value, 1); - } - - public interface Visitor { - T visit(EarningTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EarningType.class); - } - - @java.lang.Override - public EarningType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EarningTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/Employee.java b/src/main/java/com/merge/api/resources/hris/types/Employee.java index 9b9c58e76..84d93fbed 100644 --- a/src/main/java/com/merge/api/resources/hris/types/Employee.java +++ b/src/main/java/com/merge/api/resources/hris/types/Employee.java @@ -67,11 +67,11 @@ public final class Employee { private final Optional ssn; - private final Optional gender; + private final Optional gender; - private final Optional ethnicity; + private final Optional ethnicity; - private final Optional maritalStatus; + private final Optional maritalStatus; private final Optional dateOfBirth; @@ -81,7 +81,7 @@ public final class Employee { private final Optional remoteCreatedAt; - private final Optional employmentStatus; + private final Optional employmentStatus; private final Optional terminationDate; @@ -120,14 +120,14 @@ private Employee( Optional team, Optional payGroup, Optional ssn, - Optional gender, - Optional ethnicity, - Optional maritalStatus, + Optional gender, + Optional ethnicity, + Optional maritalStatus, Optional dateOfBirth, Optional hireDate, Optional startDate, Optional remoteCreatedAt, - Optional employmentStatus, + Optional employmentStatus, Optional terminationDate, Optional avatar, Optional> customFields, @@ -355,7 +355,7 @@ public Optional getSsn() { * */ @JsonProperty("gender") - public Optional getGender() { + public Optional getGender() { return gender; } @@ -373,7 +373,7 @@ public Optional getGender() { * */ @JsonProperty("ethnicity") - public Optional getEthnicity() { + public Optional getEthnicity() { return ethnicity; } @@ -388,7 +388,7 @@ public Optional getEthnicity() { * */ @JsonProperty("marital_status") - public Optional getMaritalStatus() { + public Optional getMaritalStatus() { return maritalStatus; } @@ -433,7 +433,7 @@ public Optional getRemoteCreatedAt() { * */ @JsonProperty("employment_status") - public Optional getEmploymentStatus() { + public Optional getEmploymentStatus() { return employmentStatus; } @@ -625,11 +625,11 @@ public static final class Builder { private Optional ssn = Optional.empty(); - private Optional gender = Optional.empty(); + private Optional gender = Optional.empty(); - private Optional ethnicity = Optional.empty(); + private Optional ethnicity = Optional.empty(); - private Optional maritalStatus = Optional.empty(); + private Optional maritalStatus = Optional.empty(); private Optional dateOfBirth = Optional.empty(); @@ -639,7 +639,7 @@ public static final class Builder { private Optional remoteCreatedAt = Optional.empty(); - private Optional employmentStatus = Optional.empty(); + private Optional employmentStatus = Optional.empty(); private Optional terminationDate = Optional.empty(); @@ -941,34 +941,34 @@ public Builder ssn(String ssn) { } @JsonSetter(value = "gender", nulls = Nulls.SKIP) - public Builder gender(Optional gender) { + public Builder gender(Optional gender) { this.gender = gender; return this; } - public Builder gender(EmployeeGender gender) { + public Builder gender(GenderEnum gender) { this.gender = Optional.ofNullable(gender); return this; } @JsonSetter(value = "ethnicity", nulls = Nulls.SKIP) - public Builder ethnicity(Optional ethnicity) { + public Builder ethnicity(Optional ethnicity) { this.ethnicity = ethnicity; return this; } - public Builder ethnicity(EmployeeEthnicity ethnicity) { + public Builder ethnicity(EthnicityEnum ethnicity) { this.ethnicity = Optional.ofNullable(ethnicity); return this; } @JsonSetter(value = "marital_status", nulls = Nulls.SKIP) - public Builder maritalStatus(Optional maritalStatus) { + public Builder maritalStatus(Optional maritalStatus) { this.maritalStatus = maritalStatus; return this; } - public Builder maritalStatus(EmployeeMaritalStatus maritalStatus) { + public Builder maritalStatus(MaritalStatusEnum maritalStatus) { this.maritalStatus = Optional.ofNullable(maritalStatus); return this; } @@ -1018,12 +1018,12 @@ public Builder remoteCreatedAt(OffsetDateTime remoteCreatedAt) { } @JsonSetter(value = "employment_status", nulls = Nulls.SKIP) - public Builder employmentStatus(Optional employmentStatus) { + public Builder employmentStatus(Optional employmentStatus) { this.employmentStatus = employmentStatus; return this; } - public Builder employmentStatus(EmployeeEmploymentStatus employmentStatus) { + public Builder employmentStatus(EmploymentStatusEnum employmentStatus) { this.employmentStatus = Optional.ofNullable(employmentStatus); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeCompany.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeCompany.java index 995bd4ce5..ff4f49e72 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeCompany.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmployeeCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeEmploymentStatus.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeEmploymentStatus.java deleted file mode 100644 index 328dab65a..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeEmploymentStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmployeeEmploymentStatus.Deserializer.class) -public final class EmployeeEmploymentStatus { - private final Object value; - - private final int type; - - private EmployeeEmploymentStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EmploymentStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmployeeEmploymentStatus && equalTo((EmployeeEmploymentStatus) other); - } - - private boolean equalTo(EmployeeEmploymentStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmployeeEmploymentStatus of(EmploymentStatusEnum value) { - return new EmployeeEmploymentStatus(value, 0); - } - - public static EmployeeEmploymentStatus of(String value) { - return new EmployeeEmploymentStatus(value, 1); - } - - public interface Visitor { - T visit(EmploymentStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmployeeEmploymentStatus.class); - } - - @java.lang.Override - public EmployeeEmploymentStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EmploymentStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeEmploymentsItem.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeEmploymentsItem.java index 9f3f5b3ff..72e38fb37 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeEmploymentsItem.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeEmploymentsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public EmployeeEmploymentsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeEmploymentsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeEthnicity.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeEthnicity.java deleted file mode 100644 index e5e8baa3a..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeEthnicity.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmployeeEthnicity.Deserializer.class) -public final class EmployeeEthnicity { - private final Object value; - - private final int type; - - private EmployeeEthnicity(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EthnicityEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmployeeEthnicity && equalTo((EmployeeEthnicity) other); - } - - private boolean equalTo(EmployeeEthnicity other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmployeeEthnicity of(EthnicityEnum value) { - return new EmployeeEthnicity(value, 0); - } - - public static EmployeeEthnicity of(String value) { - return new EmployeeEthnicity(value, 1); - } - - public interface Visitor { - T visit(EthnicityEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmployeeEthnicity.class); - } - - @java.lang.Override - public EmployeeEthnicity deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EthnicityEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeGender.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeGender.java deleted file mode 100644 index b43f275c5..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeGender.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmployeeGender.Deserializer.class) -public final class EmployeeGender { - private final Object value; - - private final int type; - - private EmployeeGender(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((GenderEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmployeeGender && equalTo((EmployeeGender) other); - } - - private boolean equalTo(EmployeeGender other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmployeeGender of(GenderEnum value) { - return new EmployeeGender(value, 0); - } - - public static EmployeeGender of(String value) { - return new EmployeeGender(value, 1); - } - - public interface Visitor { - T visit(GenderEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmployeeGender.class); - } - - @java.lang.Override - public EmployeeGender deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, GenderEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeGroupsItem.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeGroupsItem.java index 3da2da8a3..698d7d807 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeGroupsItem.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeGroupsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmployeeGroupsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeGroupsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeHomeLocation.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeHomeLocation.java index b38e370db..6f0c37055 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeHomeLocation.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeHomeLocation.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmployeeHomeLocation deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeHomeLocation deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeManager.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeManager.java index 2d4195fb6..1a38ce684 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeManager.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeManager.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmployeeManager deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeManager deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeMaritalStatus.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeMaritalStatus.java deleted file mode 100644 index 924230058..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeMaritalStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmployeeMaritalStatus.Deserializer.class) -public final class EmployeeMaritalStatus { - private final Object value; - - private final int type; - - private EmployeeMaritalStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((MaritalStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmployeeMaritalStatus && equalTo((EmployeeMaritalStatus) other); - } - - private boolean equalTo(EmployeeMaritalStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmployeeMaritalStatus of(MaritalStatusEnum value) { - return new EmployeeMaritalStatus(value, 0); - } - - public static EmployeeMaritalStatus of(String value) { - return new EmployeeMaritalStatus(value, 1); - } - - public interface Visitor { - T visit(MaritalStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmployeeMaritalStatus.class); - } - - @java.lang.Override - public EmployeeMaritalStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, MaritalStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeePayGroup.java b/src/main/java/com/merge/api/resources/hris/types/EmployeePayGroup.java index be598a8ea..d90285314 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeePayGroup.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeePayGroup.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmployeePayGroup deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeePayGroup deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeePayrollRunEmployee.java b/src/main/java/com/merge/api/resources/hris/types/EmployeePayrollRunEmployee.java index 4f9879b19..71400feda 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeePayrollRunEmployee.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeePayrollRunEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer ssn; - private final Optional gender; + private final Optional gender; - private final Optional ethnicity; + private final Optional ethnicity; - private final Optional maritalStatus; + private final Optional maritalStatus; private final Optional dateOfBirth; @@ -71,7 +71,7 @@ public final class EmployeeRequest { private final Optional startDate; - private final Optional employmentStatus; + private final Optional employmentStatus; private final Optional terminationDate; @@ -102,13 +102,13 @@ private EmployeeRequest( Optional team, Optional payGroup, Optional ssn, - Optional gender, - Optional ethnicity, - Optional maritalStatus, + Optional gender, + Optional ethnicity, + Optional maritalStatus, Optional dateOfBirth, Optional hireDate, Optional startDate, - Optional employmentStatus, + Optional employmentStatus, Optional terminationDate, Optional avatar, Optional> integrationParams, @@ -298,7 +298,7 @@ public Optional getSsn() { * */ @JsonProperty("gender") - public Optional getGender() { + public Optional getGender() { return gender; } @@ -316,7 +316,7 @@ public Optional getGender() { * */ @JsonProperty("ethnicity") - public Optional getEthnicity() { + public Optional getEthnicity() { return ethnicity; } @@ -331,7 +331,7 @@ public Optional getEthnicity() { * */ @JsonProperty("marital_status") - public Optional getMaritalStatus() { + public Optional getMaritalStatus() { return maritalStatus; } @@ -368,7 +368,7 @@ public Optional getStartDate() { * */ @JsonProperty("employment_status") - public Optional getEmploymentStatus() { + public Optional getEmploymentStatus() { return employmentStatus; } @@ -522,11 +522,11 @@ public static final class Builder { private Optional ssn = Optional.empty(); - private Optional gender = Optional.empty(); + private Optional gender = Optional.empty(); - private Optional ethnicity = Optional.empty(); + private Optional ethnicity = Optional.empty(); - private Optional maritalStatus = Optional.empty(); + private Optional maritalStatus = Optional.empty(); private Optional dateOfBirth = Optional.empty(); @@ -534,7 +534,7 @@ public static final class Builder { private Optional startDate = Optional.empty(); - private Optional employmentStatus = Optional.empty(); + private Optional employmentStatus = Optional.empty(); private Optional terminationDate = Optional.empty(); @@ -781,34 +781,34 @@ public Builder ssn(String ssn) { } @JsonSetter(value = "gender", nulls = Nulls.SKIP) - public Builder gender(Optional gender) { + public Builder gender(Optional gender) { this.gender = gender; return this; } - public Builder gender(EmployeeRequestGender gender) { + public Builder gender(GenderEnum gender) { this.gender = Optional.ofNullable(gender); return this; } @JsonSetter(value = "ethnicity", nulls = Nulls.SKIP) - public Builder ethnicity(Optional ethnicity) { + public Builder ethnicity(Optional ethnicity) { this.ethnicity = ethnicity; return this; } - public Builder ethnicity(EmployeeRequestEthnicity ethnicity) { + public Builder ethnicity(EthnicityEnum ethnicity) { this.ethnicity = Optional.ofNullable(ethnicity); return this; } @JsonSetter(value = "marital_status", nulls = Nulls.SKIP) - public Builder maritalStatus(Optional maritalStatus) { + public Builder maritalStatus(Optional maritalStatus) { this.maritalStatus = maritalStatus; return this; } - public Builder maritalStatus(EmployeeRequestMaritalStatus maritalStatus) { + public Builder maritalStatus(MaritalStatusEnum maritalStatus) { this.maritalStatus = Optional.ofNullable(maritalStatus); return this; } @@ -847,12 +847,12 @@ public Builder startDate(OffsetDateTime startDate) { } @JsonSetter(value = "employment_status", nulls = Nulls.SKIP) - public Builder employmentStatus(Optional employmentStatus) { + public Builder employmentStatus(Optional employmentStatus) { this.employmentStatus = employmentStatus; return this; } - public Builder employmentStatus(EmployeeRequestEmploymentStatus employmentStatus) { + public Builder employmentStatus(EmploymentStatusEnum employmentStatus) { this.employmentStatus = Optional.ofNullable(employmentStatus); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestCompany.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestCompany.java index e4747ef60..fefd16ae6 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestCompany.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestCompany.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public EmployeeRequestCompany deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeRequestCompany deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestEmploymentStatus.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestEmploymentStatus.java deleted file mode 100644 index 9a518e650..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestEmploymentStatus.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmployeeRequestEmploymentStatus.Deserializer.class) -public final class EmployeeRequestEmploymentStatus { - private final Object value; - - private final int type; - - private EmployeeRequestEmploymentStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EmploymentStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmployeeRequestEmploymentStatus && equalTo((EmployeeRequestEmploymentStatus) other); - } - - private boolean equalTo(EmployeeRequestEmploymentStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmployeeRequestEmploymentStatus of(EmploymentStatusEnum value) { - return new EmployeeRequestEmploymentStatus(value, 0); - } - - public static EmployeeRequestEmploymentStatus of(String value) { - return new EmployeeRequestEmploymentStatus(value, 1); - } - - public interface Visitor { - T visit(EmploymentStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmployeeRequestEmploymentStatus.class); - } - - @java.lang.Override - public EmployeeRequestEmploymentStatus deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EmploymentStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestEmploymentsItem.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestEmploymentsItem.java index bc8793854..1ea64114c 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestEmploymentsItem.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestEmploymentsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EthnicityEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmployeeRequestEthnicity && equalTo((EmployeeRequestEthnicity) other); - } - - private boolean equalTo(EmployeeRequestEthnicity other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmployeeRequestEthnicity of(EthnicityEnum value) { - return new EmployeeRequestEthnicity(value, 0); - } - - public static EmployeeRequestEthnicity of(String value) { - return new EmployeeRequestEthnicity(value, 1); - } - - public interface Visitor { - T visit(EthnicityEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmployeeRequestEthnicity.class); - } - - @java.lang.Override - public EmployeeRequestEthnicity deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EthnicityEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestGender.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestGender.java deleted file mode 100644 index ae17fcda9..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestGender.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmployeeRequestGender.Deserializer.class) -public final class EmployeeRequestGender { - private final Object value; - - private final int type; - - private EmployeeRequestGender(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((GenderEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmployeeRequestGender && equalTo((EmployeeRequestGender) other); - } - - private boolean equalTo(EmployeeRequestGender other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmployeeRequestGender of(GenderEnum value) { - return new EmployeeRequestGender(value, 0); - } - - public static EmployeeRequestGender of(String value) { - return new EmployeeRequestGender(value, 1); - } - - public interface Visitor { - T visit(GenderEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmployeeRequestGender.class); - } - - @java.lang.Override - public EmployeeRequestGender deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, GenderEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestGroupsItem.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestGroupsItem.java index 31b644dbb..50e794c5e 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestGroupsItem.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestGroupsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public EmployeeRequestManager deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeRequestManager deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestMaritalStatus.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestMaritalStatus.java deleted file mode 100644 index 269e17802..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestMaritalStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmployeeRequestMaritalStatus.Deserializer.class) -public final class EmployeeRequestMaritalStatus { - private final Object value; - - private final int type; - - private EmployeeRequestMaritalStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((MaritalStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmployeeRequestMaritalStatus && equalTo((EmployeeRequestMaritalStatus) other); - } - - private boolean equalTo(EmployeeRequestMaritalStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmployeeRequestMaritalStatus of(MaritalStatusEnum value) { - return new EmployeeRequestMaritalStatus(value, 0); - } - - public static EmployeeRequestMaritalStatus of(String value) { - return new EmployeeRequestMaritalStatus(value, 1); - } - - public interface Visitor { - T visit(MaritalStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmployeeRequestMaritalStatus.class); - } - - @java.lang.Override - public EmployeeRequestMaritalStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, MaritalStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestPayGroup.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestPayGroup.java index 15849e3aa..bc05252bc 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestPayGroup.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestPayGroup.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public EmployeeRequestPayGroup deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeRequestPayGroup deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestTeam.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestTeam.java index 38ec18cfb..508a48f89 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestTeam.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestTeam.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmployeeRequestTeam deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeRequestTeam deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestWorkLocation.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestWorkLocation.java index 733ccfb7e..6a14822f3 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestWorkLocation.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeRequestWorkLocation.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmployeeTeam deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeTeam deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployeeWorkLocation.java b/src/main/java/com/merge/api/resources/hris/types/EmployeeWorkLocation.java index 749eb6fb0..c91b7ee99 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployeeWorkLocation.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployeeWorkLocation.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmployeeWorkLocation deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmployeeWorkLocation deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployerBenefit.java b/src/main/java/com/merge/api/resources/hris/types/EmployerBenefit.java index 95a11dd3d..a2b10aaea 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmployerBenefit.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmployerBenefit.java @@ -31,7 +31,7 @@ public final class EmployerBenefit { private final Optional modifiedAt; - private final Optional benefitPlanType; + private final Optional benefitPlanType; private final Optional name; @@ -52,7 +52,7 @@ private EmployerBenefit( Optional remoteId, Optional createdAt, Optional modifiedAt, - Optional benefitPlanType, + Optional benefitPlanType, Optional name, Optional description, Optional deductionCode, @@ -114,7 +114,7 @@ public Optional getModifiedAt() { * */ @JsonProperty("benefit_plan_type") - public Optional getBenefitPlanType() { + public Optional getBenefitPlanType() { return benefitPlanType; } @@ -220,7 +220,7 @@ public static final class Builder { private Optional modifiedAt = Optional.empty(); - private Optional benefitPlanType = Optional.empty(); + private Optional benefitPlanType = Optional.empty(); private Optional name = Optional.empty(); @@ -299,12 +299,12 @@ public Builder modifiedAt(OffsetDateTime modifiedAt) { } @JsonSetter(value = "benefit_plan_type", nulls = Nulls.SKIP) - public Builder benefitPlanType(Optional benefitPlanType) { + public Builder benefitPlanType(Optional benefitPlanType) { this.benefitPlanType = benefitPlanType; return this; } - public Builder benefitPlanType(EmployerBenefitBenefitPlanType benefitPlanType) { + public Builder benefitPlanType(BenefitPlanTypeEnum benefitPlanType) { this.benefitPlanType = Optional.ofNullable(benefitPlanType); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/EmployerBenefitBenefitPlanType.java b/src/main/java/com/merge/api/resources/hris/types/EmployerBenefitBenefitPlanType.java deleted file mode 100644 index d93d7b152..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmployerBenefitBenefitPlanType.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmployerBenefitBenefitPlanType.Deserializer.class) -public final class EmployerBenefitBenefitPlanType { - private final Object value; - - private final int type; - - private EmployerBenefitBenefitPlanType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((BenefitPlanTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmployerBenefitBenefitPlanType && equalTo((EmployerBenefitBenefitPlanType) other); - } - - private boolean equalTo(EmployerBenefitBenefitPlanType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmployerBenefitBenefitPlanType of(BenefitPlanTypeEnum value) { - return new EmployerBenefitBenefitPlanType(value, 0); - } - - public static EmployerBenefitBenefitPlanType of(String value) { - return new EmployerBenefitBenefitPlanType(value, 1); - } - - public interface Visitor { - T visit(BenefitPlanTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmployerBenefitBenefitPlanType.class); - } - - @java.lang.Override - public EmployerBenefitBenefitPlanType deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, BenefitPlanTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/Employment.java b/src/main/java/com/merge/api/resources/hris/types/Employment.java index f55590829..b65391035 100644 --- a/src/main/java/com/merge/api/resources/hris/types/Employment.java +++ b/src/main/java/com/merge/api/resources/hris/types/Employment.java @@ -37,19 +37,19 @@ public final class Employment { private final Optional payRate; - private final Optional payPeriod; + private final Optional payPeriod; - private final Optional payFrequency; + private final Optional payFrequency; - private final Optional payCurrency; + private final Optional payCurrency; private final Optional payGroup; - private final Optional flsaStatus; + private final Optional flsaStatus; private final Optional effectiveDate; - private final Optional employmentType; + private final Optional employmentType; private final Optional remoteWasDeleted; @@ -67,13 +67,13 @@ private Employment( Optional employee, Optional jobTitle, Optional payRate, - Optional payPeriod, - Optional payFrequency, - Optional payCurrency, + Optional payPeriod, + Optional payFrequency, + Optional payCurrency, Optional payGroup, - Optional flsaStatus, + Optional flsaStatus, Optional effectiveDate, - Optional employmentType, + Optional employmentType, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -166,7 +166,7 @@ public Optional getPayRate() { * */ @JsonProperty("pay_period") - public Optional getPayPeriod() { + public Optional getPayPeriod() { return payPeriod; } @@ -185,7 +185,7 @@ public Optional getPayPeriod() { * */ @JsonProperty("pay_frequency") - public Optional getPayFrequency() { + public Optional getPayFrequency() { return payFrequency; } @@ -501,7 +501,7 @@ public Optional getPayFrequency() { * */ @JsonProperty("pay_currency") - public Optional getPayCurrency() { + public Optional getPayCurrency() { return payCurrency; } @@ -523,7 +523,7 @@ public Optional getPayGroup() { * */ @JsonProperty("flsa_status") - public Optional getFlsaStatus() { + public Optional getFlsaStatus() { return flsaStatus; } @@ -546,7 +546,7 @@ public Optional getEffectiveDate() { * */ @JsonProperty("employment_type") - public Optional getEmploymentType() { + public Optional getEmploymentType() { return employmentType; } @@ -646,19 +646,19 @@ public static final class Builder { private Optional payRate = Optional.empty(); - private Optional payPeriod = Optional.empty(); + private Optional payPeriod = Optional.empty(); - private Optional payFrequency = Optional.empty(); + private Optional payFrequency = Optional.empty(); - private Optional payCurrency = Optional.empty(); + private Optional payCurrency = Optional.empty(); private Optional payGroup = Optional.empty(); - private Optional flsaStatus = Optional.empty(); + private Optional flsaStatus = Optional.empty(); private Optional effectiveDate = Optional.empty(); - private Optional employmentType = Optional.empty(); + private Optional employmentType = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -770,34 +770,34 @@ public Builder payRate(Double payRate) { } @JsonSetter(value = "pay_period", nulls = Nulls.SKIP) - public Builder payPeriod(Optional payPeriod) { + public Builder payPeriod(Optional payPeriod) { this.payPeriod = payPeriod; return this; } - public Builder payPeriod(EmploymentPayPeriod payPeriod) { + public Builder payPeriod(PayPeriodEnum payPeriod) { this.payPeriod = Optional.ofNullable(payPeriod); return this; } @JsonSetter(value = "pay_frequency", nulls = Nulls.SKIP) - public Builder payFrequency(Optional payFrequency) { + public Builder payFrequency(Optional payFrequency) { this.payFrequency = payFrequency; return this; } - public Builder payFrequency(EmploymentPayFrequency payFrequency) { + public Builder payFrequency(PayFrequencyEnum payFrequency) { this.payFrequency = Optional.ofNullable(payFrequency); return this; } @JsonSetter(value = "pay_currency", nulls = Nulls.SKIP) - public Builder payCurrency(Optional payCurrency) { + public Builder payCurrency(Optional payCurrency) { this.payCurrency = payCurrency; return this; } - public Builder payCurrency(EmploymentPayCurrency payCurrency) { + public Builder payCurrency(PayCurrencyEnum payCurrency) { this.payCurrency = Optional.ofNullable(payCurrency); return this; } @@ -814,12 +814,12 @@ public Builder payGroup(EmploymentPayGroup payGroup) { } @JsonSetter(value = "flsa_status", nulls = Nulls.SKIP) - public Builder flsaStatus(Optional flsaStatus) { + public Builder flsaStatus(Optional flsaStatus) { this.flsaStatus = flsaStatus; return this; } - public Builder flsaStatus(EmploymentFlsaStatus flsaStatus) { + public Builder flsaStatus(FlsaStatusEnum flsaStatus) { this.flsaStatus = Optional.ofNullable(flsaStatus); return this; } @@ -836,12 +836,12 @@ public Builder effectiveDate(OffsetDateTime effectiveDate) { } @JsonSetter(value = "employment_type", nulls = Nulls.SKIP) - public Builder employmentType(Optional employmentType) { + public Builder employmentType(Optional employmentType) { this.employmentType = employmentType; return this; } - public Builder employmentType(EmploymentEmploymentType employmentType) { + public Builder employmentType(EmploymentTypeEnum employmentType) { this.employmentType = Optional.ofNullable(employmentType); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/EmploymentEmployee.java b/src/main/java/com/merge/api/resources/hris/types/EmploymentEmployee.java index bf9050797..d34888f5a 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmploymentEmployee.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmploymentEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmploymentEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmploymentEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmploymentEmploymentType.java b/src/main/java/com/merge/api/resources/hris/types/EmploymentEmploymentType.java deleted file mode 100644 index 84deec3da..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmploymentEmploymentType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmploymentEmploymentType.Deserializer.class) -public final class EmploymentEmploymentType { - private final Object value; - - private final int type; - - private EmploymentEmploymentType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EmploymentTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmploymentEmploymentType && equalTo((EmploymentEmploymentType) other); - } - - private boolean equalTo(EmploymentEmploymentType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmploymentEmploymentType of(EmploymentTypeEnum value) { - return new EmploymentEmploymentType(value, 0); - } - - public static EmploymentEmploymentType of(String value) { - return new EmploymentEmploymentType(value, 1); - } - - public interface Visitor { - T visit(EmploymentTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmploymentEmploymentType.class); - } - - @java.lang.Override - public EmploymentEmploymentType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EmploymentTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmploymentFlsaStatus.java b/src/main/java/com/merge/api/resources/hris/types/EmploymentFlsaStatus.java deleted file mode 100644 index 2761ca9ad..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmploymentFlsaStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmploymentFlsaStatus.Deserializer.class) -public final class EmploymentFlsaStatus { - private final Object value; - - private final int type; - - private EmploymentFlsaStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((FlsaStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmploymentFlsaStatus && equalTo((EmploymentFlsaStatus) other); - } - - private boolean equalTo(EmploymentFlsaStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmploymentFlsaStatus of(FlsaStatusEnum value) { - return new EmploymentFlsaStatus(value, 0); - } - - public static EmploymentFlsaStatus of(String value) { - return new EmploymentFlsaStatus(value, 1); - } - - public interface Visitor { - T visit(FlsaStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmploymentFlsaStatus.class); - } - - @java.lang.Override - public EmploymentFlsaStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FlsaStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmploymentPayCurrency.java b/src/main/java/com/merge/api/resources/hris/types/EmploymentPayCurrency.java deleted file mode 100644 index 426c63998..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmploymentPayCurrency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmploymentPayCurrency.Deserializer.class) -public final class EmploymentPayCurrency { - private final Object value; - - private final int type; - - private EmploymentPayCurrency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PayCurrencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmploymentPayCurrency && equalTo((EmploymentPayCurrency) other); - } - - private boolean equalTo(EmploymentPayCurrency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmploymentPayCurrency of(PayCurrencyEnum value) { - return new EmploymentPayCurrency(value, 0); - } - - public static EmploymentPayCurrency of(String value) { - return new EmploymentPayCurrency(value, 1); - } - - public interface Visitor { - T visit(PayCurrencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmploymentPayCurrency.class); - } - - @java.lang.Override - public EmploymentPayCurrency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PayCurrencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmploymentPayFrequency.java b/src/main/java/com/merge/api/resources/hris/types/EmploymentPayFrequency.java deleted file mode 100644 index d177c8f0d..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmploymentPayFrequency.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmploymentPayFrequency.Deserializer.class) -public final class EmploymentPayFrequency { - private final Object value; - - private final int type; - - private EmploymentPayFrequency(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PayFrequencyEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmploymentPayFrequency && equalTo((EmploymentPayFrequency) other); - } - - private boolean equalTo(EmploymentPayFrequency other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmploymentPayFrequency of(PayFrequencyEnum value) { - return new EmploymentPayFrequency(value, 0); - } - - public static EmploymentPayFrequency of(String value) { - return new EmploymentPayFrequency(value, 1); - } - - public interface Visitor { - T visit(PayFrequencyEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmploymentPayFrequency.class); - } - - @java.lang.Override - public EmploymentPayFrequency deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PayFrequencyEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EmploymentPayGroup.java b/src/main/java/com/merge/api/resources/hris/types/EmploymentPayGroup.java index 115e641ac..b190842c3 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EmploymentPayGroup.java +++ b/src/main/java/com/merge/api/resources/hris/types/EmploymentPayGroup.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public EmploymentPayGroup deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public EmploymentPayGroup deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/EmploymentPayPeriod.java b/src/main/java/com/merge/api/resources/hris/types/EmploymentPayPeriod.java deleted file mode 100644 index b332d461e..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/EmploymentPayPeriod.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = EmploymentPayPeriod.Deserializer.class) -public final class EmploymentPayPeriod { - private final Object value; - - private final int type; - - private EmploymentPayPeriod(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PayPeriodEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmploymentPayPeriod && equalTo((EmploymentPayPeriod) other); - } - - private boolean equalTo(EmploymentPayPeriod other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static EmploymentPayPeriod of(PayPeriodEnum value) { - return new EmploymentPayPeriod(value, 0); - } - - public static EmploymentPayPeriod of(String value) { - return new EmploymentPayPeriod(value, 1); - } - - public interface Visitor { - T visit(PayPeriodEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(EmploymentPayPeriod.class); - } - - @java.lang.Override - public EmploymentPayPeriod deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PayPeriodEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/EventTypeEnum.java b/src/main/java/com/merge/api/resources/hris/types/EventTypeEnum.java index 46d5e89eb..a861355e2 100644 --- a/src/main/java/com/merge/api/resources/hris/types/EventTypeEnum.java +++ b/src/main/java/com/merge/api/resources/hris/types/EventTypeEnum.java @@ -24,6 +24,8 @@ public enum EventTypeEnum { DELETED_LINKED_ACCOUNT("DELETED_LINKED_ACCOUNT"), + DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT("DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT"), + CREATED_DESTINATION("CREATED_DESTINATION"), DELETED_DESTINATION("DELETED_DESTINATION"), diff --git a/src/main/java/com/merge/api/resources/hris/types/Group.java b/src/main/java/com/merge/api/resources/hris/types/Group.java index 451b13783..d464f4ca7 100644 --- a/src/main/java/com/merge/api/resources/hris/types/Group.java +++ b/src/main/java/com/merge/api/resources/hris/types/Group.java @@ -35,12 +35,12 @@ public final class Group { private final Optional name; - private final Optional type; - - private final Optional remoteWasDeleted; + private final Optional type; private final Optional isCommonlyUsedAsTeam; + private final Optional remoteWasDeleted; + private final Optional> fieldMappings; private final Optional> remoteData; @@ -54,9 +54,9 @@ private Group( Optional modifiedAt, Optional parentGroup, Optional name, - Optional type, - Optional remoteWasDeleted, + Optional type, Optional isCommonlyUsedAsTeam, + Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, Map additionalProperties) { @@ -67,8 +67,8 @@ private Group( this.parentGroup = parentGroup; this.name = name; this.type = type; - this.remoteWasDeleted = remoteWasDeleted; this.isCommonlyUsedAsTeam = isCommonlyUsedAsTeam; + this.remoteWasDeleted = remoteWasDeleted; this.fieldMappings = fieldMappings; this.remoteData = remoteData; this.additionalProperties = additionalProperties; @@ -130,18 +130,10 @@ public Optional getName() { * */ @JsonProperty("type") - public Optional getType() { + public Optional getType() { return type; } - /** - * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. - */ - @JsonProperty("remote_was_deleted") - public Optional getRemoteWasDeleted() { - return remoteWasDeleted; - } - /** * @return Indicates whether the Group refers to a team in the third party platform. Note that this is an opinionated view based on how Merge observes most organizations representing teams in each third party platform. If your customer uses a platform different from most, there is a chance this will not be correct. */ @@ -150,6 +142,14 @@ public Optional getIsCommonlyUsedAsTeam() { return isCommonlyUsedAsTeam; } + /** + * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. + */ + @JsonProperty("remote_was_deleted") + public Optional getRemoteWasDeleted() { + return remoteWasDeleted; + } + @JsonProperty("field_mappings") public Optional> getFieldMappings() { return fieldMappings; @@ -179,8 +179,8 @@ private boolean equalTo(Group other) { && parentGroup.equals(other.parentGroup) && name.equals(other.name) && type.equals(other.type) - && remoteWasDeleted.equals(other.remoteWasDeleted) && isCommonlyUsedAsTeam.equals(other.isCommonlyUsedAsTeam) + && remoteWasDeleted.equals(other.remoteWasDeleted) && fieldMappings.equals(other.fieldMappings) && remoteData.equals(other.remoteData); } @@ -195,8 +195,8 @@ public int hashCode() { this.parentGroup, this.name, this.type, - this.remoteWasDeleted, this.isCommonlyUsedAsTeam, + this.remoteWasDeleted, this.fieldMappings, this.remoteData); } @@ -224,12 +224,12 @@ public static final class Builder { private Optional name = Optional.empty(); - private Optional type = Optional.empty(); - - private Optional remoteWasDeleted = Optional.empty(); + private Optional type = Optional.empty(); private Optional isCommonlyUsedAsTeam = Optional.empty(); + private Optional remoteWasDeleted = Optional.empty(); + private Optional> fieldMappings = Optional.empty(); private Optional> remoteData = Optional.empty(); @@ -247,8 +247,8 @@ public Builder from(Group other) { parentGroup(other.getParentGroup()); name(other.getName()); type(other.getType()); - remoteWasDeleted(other.getRemoteWasDeleted()); isCommonlyUsedAsTeam(other.getIsCommonlyUsedAsTeam()); + remoteWasDeleted(other.getRemoteWasDeleted()); fieldMappings(other.getFieldMappings()); remoteData(other.getRemoteData()); return this; @@ -321,35 +321,35 @@ public Builder name(String name) { } @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { + public Builder type(Optional type) { this.type = type; return this; } - public Builder type(GroupType type) { + public Builder type(GroupTypeEnum type) { this.type = Optional.ofNullable(type); return this; } - @JsonSetter(value = "remote_was_deleted", nulls = Nulls.SKIP) - public Builder remoteWasDeleted(Optional remoteWasDeleted) { - this.remoteWasDeleted = remoteWasDeleted; + @JsonSetter(value = "is_commonly_used_as_team", nulls = Nulls.SKIP) + public Builder isCommonlyUsedAsTeam(Optional isCommonlyUsedAsTeam) { + this.isCommonlyUsedAsTeam = isCommonlyUsedAsTeam; return this; } - public Builder remoteWasDeleted(Boolean remoteWasDeleted) { - this.remoteWasDeleted = Optional.ofNullable(remoteWasDeleted); + public Builder isCommonlyUsedAsTeam(Boolean isCommonlyUsedAsTeam) { + this.isCommonlyUsedAsTeam = Optional.ofNullable(isCommonlyUsedAsTeam); return this; } - @JsonSetter(value = "is_commonly_used_as_team", nulls = Nulls.SKIP) - public Builder isCommonlyUsedAsTeam(Optional isCommonlyUsedAsTeam) { - this.isCommonlyUsedAsTeam = isCommonlyUsedAsTeam; + @JsonSetter(value = "remote_was_deleted", nulls = Nulls.SKIP) + public Builder remoteWasDeleted(Optional remoteWasDeleted) { + this.remoteWasDeleted = remoteWasDeleted; return this; } - public Builder isCommonlyUsedAsTeam(Boolean isCommonlyUsedAsTeam) { - this.isCommonlyUsedAsTeam = Optional.ofNullable(isCommonlyUsedAsTeam); + public Builder remoteWasDeleted(Boolean remoteWasDeleted) { + this.remoteWasDeleted = Optional.ofNullable(remoteWasDeleted); return this; } @@ -384,8 +384,8 @@ public Group build() { parentGroup, name, type, - remoteWasDeleted, isCommonlyUsedAsTeam, + remoteWasDeleted, fieldMappings, remoteData, additionalProperties); diff --git a/src/main/java/com/merge/api/resources/hris/types/GroupType.java b/src/main/java/com/merge/api/resources/hris/types/GroupType.java deleted file mode 100644 index e67c7da72..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/GroupType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = GroupType.Deserializer.class) -public final class GroupType { - private final Object value; - - private final int type; - - private GroupType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((GroupTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GroupType && equalTo((GroupType) other); - } - - private boolean equalTo(GroupType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static GroupType of(GroupTypeEnum value) { - return new GroupType(value, 0); - } - - public static GroupType of(String value) { - return new GroupType(value, 1); - } - - public interface Visitor { - T visit(GroupTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(GroupType.class); - } - - @java.lang.Override - public GroupType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, GroupTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/IgnoreCommonModelRequest.java b/src/main/java/com/merge/api/resources/hris/types/IgnoreCommonModelRequest.java new file mode 100644 index 000000000..8b8e018cb --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/types/IgnoreCommonModelRequest.java @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = IgnoreCommonModelRequest.Builder.class) +public final class IgnoreCommonModelRequest { + private final ReasonEnum reason; + + private final Optional message; + + private final Map additionalProperties; + + private IgnoreCommonModelRequest( + ReasonEnum reason, Optional message, Map additionalProperties) { + this.reason = reason; + this.message = message; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("reason") + public ReasonEnum getReason() { + return reason; + } + + @JsonProperty("message") + public Optional getMessage() { + return message; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof IgnoreCommonModelRequest && equalTo((IgnoreCommonModelRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(IgnoreCommonModelRequest other) { + return reason.equals(other.reason) && message.equals(other.message); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.reason, this.message); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ReasonStage builder() { + return new Builder(); + } + + public interface ReasonStage { + _FinalStage reason(@NotNull ReasonEnum reason); + + Builder from(IgnoreCommonModelRequest other); + } + + public interface _FinalStage { + IgnoreCommonModelRequest build(); + + _FinalStage message(Optional message); + + _FinalStage message(String message); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ReasonStage, _FinalStage { + private ReasonEnum reason; + + private Optional message = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(IgnoreCommonModelRequest other) { + reason(other.getReason()); + message(other.getMessage()); + return this; + } + + @java.lang.Override + @JsonSetter("reason") + public _FinalStage reason(@NotNull ReasonEnum reason) { + this.reason = reason; + return this; + } + + @java.lang.Override + public _FinalStage message(String message) { + this.message = Optional.ofNullable(message); + return this; + } + + @java.lang.Override + @JsonSetter(value = "message", nulls = Nulls.SKIP) + public _FinalStage message(Optional message) { + this.message = message; + return this; + } + + @java.lang.Override + public IgnoreCommonModelRequest build() { + return new IgnoreCommonModelRequest(reason, message, additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/types/Issue.java b/src/main/java/com/merge/api/resources/hris/types/Issue.java index e6d294ea0..8866be008 100644 --- a/src/main/java/com/merge/api/resources/hris/types/Issue.java +++ b/src/main/java/com/merge/api/resources/hris/types/Issue.java @@ -26,7 +26,7 @@ public final class Issue { private final Optional id; - private final Optional status; + private final Optional status; private final String errorDescription; @@ -44,7 +44,7 @@ public final class Issue { private Issue( Optional id, - Optional status, + Optional status, String errorDescription, Optional> endUser, Optional firstIncidentTime, @@ -76,7 +76,7 @@ public Optional getId() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -167,9 +167,9 @@ public interface _FinalStage { _FinalStage id(String id); - _FinalStage status(Optional status); + _FinalStage status(Optional status); - _FinalStage status(IssueStatus status); + _FinalStage status(IssueStatusEnum status); _FinalStage endUser(Optional> endUser); @@ -206,7 +206,7 @@ public static final class Builder implements ErrorDescriptionStage, _FinalStage private Optional> endUser = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional id = Optional.empty(); @@ -309,14 +309,14 @@ public _FinalStage endUser(Optional> endUser) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage status(IssueStatus status) { + public _FinalStage status(IssueStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @java.lang.Override @JsonSetter(value = "status", nulls = Nulls.SKIP) - public _FinalStage status(Optional status) { + public _FinalStage status(Optional status) { this.status = status; return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/IssueStatus.java b/src/main/java/com/merge/api/resources/hris/types/IssueStatus.java deleted file mode 100644 index c93308502..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/IssueStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = IssueStatus.Deserializer.class) -public final class IssueStatus { - private final Object value; - - private final int type; - - private IssueStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((IssueStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IssueStatus && equalTo((IssueStatus) other); - } - - private boolean equalTo(IssueStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static IssueStatus of(IssueStatusEnum value) { - return new IssueStatus(value, 0); - } - - public static IssueStatus of(String value) { - return new IssueStatus(value, 1); - } - - public interface Visitor { - T visit(IssueStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(IssueStatus.class); - } - - @java.lang.Override - public IssueStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, IssueStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/LastSyncResultEnum.java b/src/main/java/com/merge/api/resources/hris/types/LastSyncResultEnum.java new file mode 100644 index 000000000..72fed4544 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/types/LastSyncResultEnum.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum LastSyncResultEnum { + SYNCING("SYNCING"), + + DONE("DONE"), + + FAILED("FAILED"), + + DISABLED("DISABLED"), + + PAUSED("PAUSED"), + + PARTIALLY_SYNCED("PARTIALLY_SYNCED"); + + private final String value; + + LastSyncResultEnum(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/types/Location.java b/src/main/java/com/merge/api/resources/hris/types/Location.java index 8930c6557..fcb2e9e28 100644 --- a/src/main/java/com/merge/api/resources/hris/types/Location.java +++ b/src/main/java/com/merge/api/resources/hris/types/Location.java @@ -45,9 +45,9 @@ public final class Location { private final Optional zipCode; - private final Optional country; + private final Optional country; - private final Optional locationType; + private final Optional locationType; private final Optional remoteWasDeleted; @@ -69,8 +69,8 @@ private Location( Optional city, Optional state, Optional zipCode, - Optional country, - Optional locationType, + Optional country, + Optional locationType, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -434,7 +434,7 @@ public Optional getZipCode() { * */ @JsonProperty("country") - public Optional getCountry() { + public Optional getCountry() { return country; } @@ -446,7 +446,7 @@ public Optional getCountry() { * */ @JsonProperty("location_type") - public Optional getLocationType() { + public Optional getLocationType() { return locationType; } @@ -552,9 +552,9 @@ public static final class Builder { private Optional zipCode = Optional.empty(); - private Optional country = Optional.empty(); + private Optional country = Optional.empty(); - private Optional locationType = Optional.empty(); + private Optional locationType = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -709,23 +709,23 @@ public Builder zipCode(String zipCode) { } @JsonSetter(value = "country", nulls = Nulls.SKIP) - public Builder country(Optional country) { + public Builder country(Optional country) { this.country = country; return this; } - public Builder country(LocationCountry country) { + public Builder country(CountryEnum country) { this.country = Optional.ofNullable(country); return this; } @JsonSetter(value = "location_type", nulls = Nulls.SKIP) - public Builder locationType(Optional locationType) { + public Builder locationType(Optional locationType) { this.locationType = locationType; return this; } - public Builder locationType(LocationLocationType locationType) { + public Builder locationType(LocationTypeEnum locationType) { this.locationType = Optional.ofNullable(locationType); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/LocationCountry.java b/src/main/java/com/merge/api/resources/hris/types/LocationCountry.java deleted file mode 100644 index f405cfb9a..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/LocationCountry.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = LocationCountry.Deserializer.class) -public final class LocationCountry { - private final Object value; - - private final int type; - - private LocationCountry(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CountryEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof LocationCountry && equalTo((LocationCountry) other); - } - - private boolean equalTo(LocationCountry other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static LocationCountry of(CountryEnum value) { - return new LocationCountry(value, 0); - } - - public static LocationCountry of(String value) { - return new LocationCountry(value, 1); - } - - public interface Visitor { - T visit(CountryEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(LocationCountry.class); - } - - @java.lang.Override - public LocationCountry deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CountryEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/LocationLocationType.java b/src/main/java/com/merge/api/resources/hris/types/LocationLocationType.java deleted file mode 100644 index 91677ae17..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/LocationLocationType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = LocationLocationType.Deserializer.class) -public final class LocationLocationType { - private final Object value; - - private final int type; - - private LocationLocationType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((LocationTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof LocationLocationType && equalTo((LocationLocationType) other); - } - - private boolean equalTo(LocationLocationType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static LocationLocationType of(LocationTypeEnum value) { - return new LocationLocationType(value, 0); - } - - public static LocationLocationType of(String value) { - return new LocationLocationType(value, 1); - } - - public interface Visitor { - T visit(LocationTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(LocationLocationType.class); - } - - @java.lang.Override - public LocationLocationType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, LocationTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/MultipartFormFieldRequest.java b/src/main/java/com/merge/api/resources/hris/types/MultipartFormFieldRequest.java index 1dc2e0859..09f6c3d5a 100644 --- a/src/main/java/com/merge/api/resources/hris/types/MultipartFormFieldRequest.java +++ b/src/main/java/com/merge/api/resources/hris/types/MultipartFormFieldRequest.java @@ -25,7 +25,7 @@ public final class MultipartFormFieldRequest { private final String data; - private final Optional encoding; + private final Optional encoding; private final Optional fileName; @@ -36,7 +36,7 @@ public final class MultipartFormFieldRequest { private MultipartFormFieldRequest( String name, String data, - Optional encoding, + Optional encoding, Optional fileName, Optional contentType, Map additionalProperties) { @@ -73,7 +73,7 @@ public String getData() { * */ @JsonProperty("encoding") - public Optional getEncoding() { + public Optional getEncoding() { return encoding; } @@ -139,9 +139,9 @@ public interface DataStage { public interface _FinalStage { MultipartFormFieldRequest build(); - _FinalStage encoding(Optional encoding); + _FinalStage encoding(Optional encoding); - _FinalStage encoding(MultipartFormFieldRequestEncoding encoding); + _FinalStage encoding(EncodingEnum encoding); _FinalStage fileName(Optional fileName); @@ -162,7 +162,7 @@ public static final class Builder implements NameStage, DataStage, _FinalStage { private Optional fileName = Optional.empty(); - private Optional encoding = Optional.empty(); + private Optional encoding = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -245,14 +245,14 @@ public _FinalStage fileName(Optional fileName) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage encoding(MultipartFormFieldRequestEncoding encoding) { + public _FinalStage encoding(EncodingEnum encoding) { this.encoding = Optional.ofNullable(encoding); return this; } @java.lang.Override @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { + public _FinalStage encoding(Optional encoding) { this.encoding = encoding; return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/MultipartFormFieldRequestEncoding.java b/src/main/java/com/merge/api/resources/hris/types/MultipartFormFieldRequestEncoding.java deleted file mode 100644 index 0346026a6..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/MultipartFormFieldRequestEncoding.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = MultipartFormFieldRequestEncoding.Deserializer.class) -public final class MultipartFormFieldRequestEncoding { - private final Object value; - - private final int type; - - private MultipartFormFieldRequestEncoding(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EncodingEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MultipartFormFieldRequestEncoding && equalTo((MultipartFormFieldRequestEncoding) other); - } - - private boolean equalTo(MultipartFormFieldRequestEncoding other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static MultipartFormFieldRequestEncoding of(EncodingEnum value) { - return new MultipartFormFieldRequestEncoding(value, 0); - } - - public static MultipartFormFieldRequestEncoding of(String value) { - return new MultipartFormFieldRequestEncoding(value, 1); - } - - public interface Visitor { - T visit(EncodingEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(MultipartFormFieldRequestEncoding.class); - } - - @java.lang.Override - public MultipartFormFieldRequestEncoding deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EncodingEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/PayrollRun.java b/src/main/java/com/merge/api/resources/hris/types/PayrollRun.java index 323b2bb3b..1a333ffad 100644 --- a/src/main/java/com/merge/api/resources/hris/types/PayrollRun.java +++ b/src/main/java/com/merge/api/resources/hris/types/PayrollRun.java @@ -31,9 +31,9 @@ public final class PayrollRun { private final Optional modifiedAt; - private final Optional runState; + private final Optional runState; - private final Optional runType; + private final Optional runType; private final Optional startDate; @@ -54,8 +54,8 @@ private PayrollRun( Optional remoteId, Optional createdAt, Optional modifiedAt, - Optional runState, - Optional runType, + Optional runState, + Optional runType, Optional startDate, Optional endDate, Optional checkDate, @@ -118,7 +118,7 @@ public Optional getModifiedAt() { * */ @JsonProperty("run_state") - public Optional getRunState() { + public Optional getRunState() { return runState; } @@ -133,7 +133,7 @@ public Optional getRunState() { * */ @JsonProperty("run_type") - public Optional getRunType() { + public Optional getRunType() { return runType; } @@ -241,9 +241,9 @@ public static final class Builder { private Optional modifiedAt = Optional.empty(); - private Optional runState = Optional.empty(); + private Optional runState = Optional.empty(); - private Optional runType = Optional.empty(); + private Optional runType = Optional.empty(); private Optional startDate = Optional.empty(); @@ -323,23 +323,23 @@ public Builder modifiedAt(OffsetDateTime modifiedAt) { } @JsonSetter(value = "run_state", nulls = Nulls.SKIP) - public Builder runState(Optional runState) { + public Builder runState(Optional runState) { this.runState = runState; return this; } - public Builder runState(PayrollRunRunState runState) { + public Builder runState(RunStateEnum runState) { this.runState = Optional.ofNullable(runState); return this; } @JsonSetter(value = "run_type", nulls = Nulls.SKIP) - public Builder runType(Optional runType) { + public Builder runType(Optional runType) { this.runType = runType; return this; } - public Builder runType(PayrollRunRunType runType) { + public Builder runType(RunTypeEnum runType) { this.runType = Optional.ofNullable(runType); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/PayrollRunRunState.java b/src/main/java/com/merge/api/resources/hris/types/PayrollRunRunState.java deleted file mode 100644 index f658b684d..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/PayrollRunRunState.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PayrollRunRunState.Deserializer.class) -public final class PayrollRunRunState { - private final Object value; - - private final int type; - - private PayrollRunRunState(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RunStateEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PayrollRunRunState && equalTo((PayrollRunRunState) other); - } - - private boolean equalTo(PayrollRunRunState other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PayrollRunRunState of(RunStateEnum value) { - return new PayrollRunRunState(value, 0); - } - - public static PayrollRunRunState of(String value) { - return new PayrollRunRunState(value, 1); - } - - public interface Visitor { - T visit(RunStateEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PayrollRunRunState.class); - } - - @java.lang.Override - public PayrollRunRunState deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RunStateEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/PayrollRunRunType.java b/src/main/java/com/merge/api/resources/hris/types/PayrollRunRunType.java deleted file mode 100644 index eddffba51..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/PayrollRunRunType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PayrollRunRunType.Deserializer.class) -public final class PayrollRunRunType { - private final Object value; - - private final int type; - - private PayrollRunRunType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RunTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PayrollRunRunType && equalTo((PayrollRunRunType) other); - } - - private boolean equalTo(PayrollRunRunType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PayrollRunRunType of(RunTypeEnum value) { - return new PayrollRunRunType(value, 0); - } - - public static PayrollRunRunType of(String value) { - return new PayrollRunRunType(value, 1); - } - - public interface Visitor { - T visit(RunTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PayrollRunRunType.class); - } - - @java.lang.Override - public PayrollRunRunType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RunTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/RemoteFieldApiCoverage.java b/src/main/java/com/merge/api/resources/hris/types/RemoteFieldApiCoverage.java index 936ccbcfd..f75f0c40e 100644 --- a/src/main/java/com/merge/api/resources/hris/types/RemoteFieldApiCoverage.java +++ b/src/main/java/com/merge/api/resources/hris/types/RemoteFieldApiCoverage.java @@ -28,6 +28,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((int) this.value); @@ -77,7 +78,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); if (value instanceof Integer) { return of((Integer) value); diff --git a/src/main/java/com/merge/api/resources/hris/types/RemoteResponse.java b/src/main/java/com/merge/api/resources/hris/types/RemoteResponse.java index eb491f762..dbbcff4df 100644 --- a/src/main/java/com/merge/api/resources/hris/types/RemoteResponse.java +++ b/src/main/java/com/merge/api/resources/hris/types/RemoteResponse.java @@ -32,7 +32,7 @@ public final class RemoteResponse { private final Optional> responseHeaders; - private final Optional responseType; + private final Optional responseType; private final Optional> headers; @@ -44,7 +44,7 @@ private RemoteResponse( int status, JsonNode response, Optional> responseHeaders, - Optional responseType, + Optional responseType, Optional> headers, Map additionalProperties) { this.method = method; @@ -83,7 +83,7 @@ public Optional> getResponseHeaders() { } @JsonProperty("response_type") - public Optional getResponseType() { + public Optional getResponseType() { return responseType; } @@ -159,9 +159,9 @@ public interface _FinalStage { _FinalStage responseHeaders(Map responseHeaders); - _FinalStage responseType(Optional responseType); + _FinalStage responseType(Optional responseType); - _FinalStage responseType(RemoteResponseResponseType responseType); + _FinalStage responseType(ResponseTypeEnum responseType); _FinalStage headers(Optional> headers); @@ -180,7 +180,7 @@ public static final class Builder implements MethodStage, PathStage, StatusStage private Optional> headers = Optional.empty(); - private Optional responseType = Optional.empty(); + private Optional responseType = Optional.empty(); private Optional> responseHeaders = Optional.empty(); @@ -243,14 +243,14 @@ public _FinalStage headers(Optional> headers) { } @java.lang.Override - public _FinalStage responseType(RemoteResponseResponseType responseType) { + public _FinalStage responseType(ResponseTypeEnum responseType) { this.responseType = Optional.ofNullable(responseType); return this; } @java.lang.Override @JsonSetter(value = "response_type", nulls = Nulls.SKIP) - public _FinalStage responseType(Optional responseType) { + public _FinalStage responseType(Optional responseType) { this.responseType = responseType; return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/RemoteResponseResponseType.java b/src/main/java/com/merge/api/resources/hris/types/RemoteResponseResponseType.java deleted file mode 100644 index e872b9f05..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/RemoteResponseResponseType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RemoteResponseResponseType.Deserializer.class) -public final class RemoteResponseResponseType { - private final Object value; - - private final int type; - - private RemoteResponseResponseType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ResponseTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RemoteResponseResponseType && equalTo((RemoteResponseResponseType) other); - } - - private boolean equalTo(RemoteResponseResponseType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RemoteResponseResponseType of(ResponseTypeEnum value) { - return new RemoteResponseResponseType(value, 0); - } - - public static RemoteResponseResponseType of(String value) { - return new RemoteResponseResponseType(value, 1); - } - - public interface Visitor { - T visit(ResponseTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RemoteResponseResponseType.class); - } - - @java.lang.Override - public RemoteResponseResponseType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ResponseTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/StatusFd5Enum.java b/src/main/java/com/merge/api/resources/hris/types/StatusFd5Enum.java new file mode 100644 index 000000000..8eb01ebfb --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/types/StatusFd5Enum.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum StatusFd5Enum { + SYNCING("SYNCING"), + + DONE("DONE"), + + FAILED("FAILED"), + + DISABLED("DISABLED"), + + PAUSED("PAUSED"), + + PARTIALLY_SYNCED("PARTIALLY_SYNCED"); + + private final String value; + + StatusFd5Enum(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/types/SyncStatus.java b/src/main/java/com/merge/api/resources/hris/types/SyncStatus.java index c94ff32c8..99d5978c0 100644 --- a/src/main/java/com/merge/api/resources/hris/types/SyncStatus.java +++ b/src/main/java/com/merge/api/resources/hris/types/SyncStatus.java @@ -30,7 +30,11 @@ public final class SyncStatus { private final Optional nextSyncStart; - private final SyncStatusStatusEnum status; + private final Optional lastSyncResult; + + private final Optional lastSyncFinished; + + private final StatusFd5Enum status; private final boolean isInitialSync; @@ -43,7 +47,9 @@ private SyncStatus( String modelId, Optional lastSyncStart, Optional nextSyncStart, - SyncStatusStatusEnum status, + Optional lastSyncResult, + Optional lastSyncFinished, + StatusFd5Enum status, boolean isInitialSync, Optional selectiveSyncConfigurationsUsage, Map additionalProperties) { @@ -51,6 +57,8 @@ private SyncStatus( this.modelId = modelId; this.lastSyncStart = lastSyncStart; this.nextSyncStart = nextSyncStart; + this.lastSyncResult = lastSyncResult; + this.lastSyncFinished = lastSyncFinished; this.status = status; this.isInitialSync = isInitialSync; this.selectiveSyncConfigurationsUsage = selectiveSyncConfigurationsUsage; @@ -77,8 +85,18 @@ public Optional getNextSyncStart() { return nextSyncStart; } + @JsonProperty("last_sync_result") + public Optional getLastSyncResult() { + return lastSyncResult; + } + + @JsonProperty("last_sync_finished") + public Optional getLastSyncFinished() { + return lastSyncFinished; + } + @JsonProperty("status") - public SyncStatusStatusEnum getStatus() { + public StatusFd5Enum getStatus() { return status; } @@ -108,6 +126,8 @@ private boolean equalTo(SyncStatus other) { && modelId.equals(other.modelId) && lastSyncStart.equals(other.lastSyncStart) && nextSyncStart.equals(other.nextSyncStart) + && lastSyncResult.equals(other.lastSyncResult) + && lastSyncFinished.equals(other.lastSyncFinished) && status.equals(other.status) && isInitialSync == other.isInitialSync && selectiveSyncConfigurationsUsage.equals(other.selectiveSyncConfigurationsUsage); @@ -120,6 +140,8 @@ public int hashCode() { this.modelId, this.lastSyncStart, this.nextSyncStart, + this.lastSyncResult, + this.lastSyncFinished, this.status, this.isInitialSync, this.selectiveSyncConfigurationsUsage); @@ -145,7 +167,7 @@ public interface ModelIdStage { } public interface StatusStage { - IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status); + IsInitialSyncStage status(@NotNull StatusFd5Enum status); } public interface IsInitialSyncStage { @@ -163,6 +185,14 @@ public interface _FinalStage { _FinalStage nextSyncStart(OffsetDateTime nextSyncStart); + _FinalStage lastSyncResult(Optional lastSyncResult); + + _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult); + + _FinalStage lastSyncFinished(Optional lastSyncFinished); + + _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished); + _FinalStage selectiveSyncConfigurationsUsage( Optional selectiveSyncConfigurationsUsage); @@ -177,12 +207,16 @@ public static final class Builder private String modelId; - private SyncStatusStatusEnum status; + private StatusFd5Enum status; private boolean isInitialSync; private Optional selectiveSyncConfigurationsUsage = Optional.empty(); + private Optional lastSyncFinished = Optional.empty(); + + private Optional lastSyncResult = Optional.empty(); + private Optional nextSyncStart = Optional.empty(); private Optional lastSyncStart = Optional.empty(); @@ -198,6 +232,8 @@ public Builder from(SyncStatus other) { modelId(other.getModelId()); lastSyncStart(other.getLastSyncStart()); nextSyncStart(other.getNextSyncStart()); + lastSyncResult(other.getLastSyncResult()); + lastSyncFinished(other.getLastSyncFinished()); status(other.getStatus()); isInitialSync(other.getIsInitialSync()); selectiveSyncConfigurationsUsage(other.getSelectiveSyncConfigurationsUsage()); @@ -220,7 +256,7 @@ public StatusStage modelId(@NotNull String modelId) { @java.lang.Override @JsonSetter("status") - public IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status) { + public IsInitialSyncStage status(@NotNull StatusFd5Enum status) { this.status = status; return this; } @@ -247,6 +283,32 @@ public _FinalStage selectiveSyncConfigurationsUsage( return this; } + @java.lang.Override + public _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished) { + this.lastSyncFinished = Optional.ofNullable(lastSyncFinished); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_finished", nulls = Nulls.SKIP) + public _FinalStage lastSyncFinished(Optional lastSyncFinished) { + this.lastSyncFinished = lastSyncFinished; + return this; + } + + @java.lang.Override + public _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult) { + this.lastSyncResult = Optional.ofNullable(lastSyncResult); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_result", nulls = Nulls.SKIP) + public _FinalStage lastSyncResult(Optional lastSyncResult) { + this.lastSyncResult = lastSyncResult; + return this; + } + @java.lang.Override public _FinalStage nextSyncStart(OffsetDateTime nextSyncStart) { this.nextSyncStart = Optional.ofNullable(nextSyncStart); @@ -280,6 +342,8 @@ public SyncStatus build() { modelId, lastSyncStart, nextSyncStart, + lastSyncResult, + lastSyncFinished, status, isInitialSync, selectiveSyncConfigurationsUsage, diff --git a/src/main/java/com/merge/api/resources/hris/types/SyncStatusStatusEnum.java b/src/main/java/com/merge/api/resources/hris/types/SyncStatusStatusEnum.java deleted file mode 100644 index e38b9a935..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/SyncStatusStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SyncStatusStatusEnum { - SYNCING("SYNCING"), - - DONE("DONE"), - - FAILED("FAILED"), - - DISABLED("DISABLED"), - - PAUSED("PAUSED"), - - PARTIALLY_SYNCED("PARTIALLY_SYNCED"); - - private final String value; - - SyncStatusStatusEnum(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/TeamParentTeam.java b/src/main/java/com/merge/api/resources/hris/types/TeamParentTeam.java index 01774d3b2..42e60a75b 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TeamParentTeam.java +++ b/src/main/java/com/merge/api/resources/hris/types/TeamParentTeam.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TeamParentTeam deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TeamParentTeam deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOff.java b/src/main/java/com/merge/api/resources/hris/types/TimeOff.java index 977c2d458..9cd2b3b83 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOff.java +++ b/src/main/java/com/merge/api/resources/hris/types/TimeOff.java @@ -35,15 +35,15 @@ public final class TimeOff { private final Optional approver; - private final Optional status; + private final Optional status; private final Optional employeeNote; - private final Optional units; + private final Optional units; private final Optional amount; - private final Optional requestType; + private final Optional requestType; private final Optional startTime; @@ -64,11 +64,11 @@ private TimeOff( Optional modifiedAt, Optional employee, Optional approver, - Optional status, + Optional status, Optional employeeNote, - Optional units, + Optional units, Optional amount, - Optional requestType, + Optional requestType, Optional startTime, Optional endTime, Optional remoteWasDeleted, @@ -150,7 +150,7 @@ public Optional getApprover() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -170,7 +170,7 @@ public Optional getEmployeeNote() { * */ @JsonProperty("units") - public Optional getUnits() { + public Optional getUnits() { return units; } @@ -194,7 +194,7 @@ public Optional getAmount() { * */ @JsonProperty("request_type") - public Optional getRequestType() { + public Optional getRequestType() { return requestType; } @@ -306,15 +306,15 @@ public static final class Builder { private Optional approver = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional employeeNote = Optional.empty(); - private Optional units = Optional.empty(); + private Optional units = Optional.empty(); private Optional amount = Optional.empty(); - private Optional requestType = Optional.empty(); + private Optional requestType = Optional.empty(); private Optional startTime = Optional.empty(); @@ -418,12 +418,12 @@ public Builder approver(TimeOffApprover approver) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(TimeOffStatus status) { + public Builder status(TimeOffStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -440,12 +440,12 @@ public Builder employeeNote(String employeeNote) { } @JsonSetter(value = "units", nulls = Nulls.SKIP) - public Builder units(Optional units) { + public Builder units(Optional units) { this.units = units; return this; } - public Builder units(TimeOffUnits units) { + public Builder units(UnitsEnum units) { this.units = Optional.ofNullable(units); return this; } @@ -462,12 +462,12 @@ public Builder amount(Double amount) { } @JsonSetter(value = "request_type", nulls = Nulls.SKIP) - public Builder requestType(Optional requestType) { + public Builder requestType(Optional requestType) { this.requestType = requestType; return this; } - public Builder requestType(TimeOffRequestType requestType) { + public Builder requestType(RequestTypeEnum requestType) { this.requestType = Optional.ofNullable(requestType); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffApprover.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffApprover.java index 04731ac86..5952e3e17 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffApprover.java +++ b/src/main/java/com/merge/api/resources/hris/types/TimeOffApprover.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TimeOffApprover deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TimeOffApprover deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffBalance.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffBalance.java index 7139c9572..8f32a9dcb 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffBalance.java +++ b/src/main/java/com/merge/api/resources/hris/types/TimeOffBalance.java @@ -37,7 +37,7 @@ public final class TimeOffBalance { private final Optional used; - private final Optional policyType; + private final Optional policyType; private final Optional remoteWasDeleted; @@ -55,7 +55,7 @@ private TimeOffBalance( Optional employee, Optional balance, Optional used, - Optional policyType, + Optional policyType, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -139,7 +139,7 @@ public Optional getUsed() { * */ @JsonProperty("policy_type") - public Optional getPolicyType() { + public Optional getPolicyType() { return policyType; } @@ -227,7 +227,7 @@ public static final class Builder { private Optional used = Optional.empty(); - private Optional policyType = Optional.empty(); + private Optional policyType = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -333,12 +333,12 @@ public Builder used(Double used) { } @JsonSetter(value = "policy_type", nulls = Nulls.SKIP) - public Builder policyType(Optional policyType) { + public Builder policyType(Optional policyType) { this.policyType = policyType; return this; } - public Builder policyType(TimeOffBalancePolicyType policyType) { + public Builder policyType(PolicyTypeEnum policyType) { this.policyType = Optional.ofNullable(policyType); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffBalanceEmployee.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffBalanceEmployee.java index b423e0d03..8fdb1e7ea 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffBalanceEmployee.java +++ b/src/main/java/com/merge/api/resources/hris/types/TimeOffBalanceEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public TimeOffBalanceEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TimeOffBalanceEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffBalancePolicyType.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffBalancePolicyType.java deleted file mode 100644 index ca9efd7d6..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffBalancePolicyType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TimeOffBalancePolicyType.Deserializer.class) -public final class TimeOffBalancePolicyType { - private final Object value; - - private final int type; - - private TimeOffBalancePolicyType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PolicyTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TimeOffBalancePolicyType && equalTo((TimeOffBalancePolicyType) other); - } - - private boolean equalTo(TimeOffBalancePolicyType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TimeOffBalancePolicyType of(PolicyTypeEnum value) { - return new TimeOffBalancePolicyType(value, 0); - } - - public static TimeOffBalancePolicyType of(String value) { - return new TimeOffBalancePolicyType(value, 1); - } - - public interface Visitor { - T visit(PolicyTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TimeOffBalancePolicyType.class); - } - - @java.lang.Override - public TimeOffBalancePolicyType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PolicyTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffEmployee.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffEmployee.java index 61d1fc928..b3a24db15 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffEmployee.java +++ b/src/main/java/com/merge/api/resources/hris/types/TimeOffEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TimeOffEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TimeOffEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequest.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffRequest.java index 31c91d796..c3b38dc6c 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequest.java +++ b/src/main/java/com/merge/api/resources/hris/types/TimeOffRequest.java @@ -26,15 +26,15 @@ public final class TimeOffRequest { private final Optional approver; - private final Optional status; + private final Optional status; private final Optional employeeNote; - private final Optional units; + private final Optional units; private final Optional amount; - private final Optional requestType; + private final Optional requestType; private final Optional startTime; @@ -49,11 +49,11 @@ public final class TimeOffRequest { private TimeOffRequest( Optional employee, Optional approver, - Optional status, + Optional status, Optional employeeNote, - Optional units, + Optional units, Optional amount, - Optional requestType, + Optional requestType, Optional startTime, Optional endTime, Optional> integrationParams, @@ -100,7 +100,7 @@ public Optional getApprover() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -120,7 +120,7 @@ public Optional getEmployeeNote() { * */ @JsonProperty("units") - public Optional getUnits() { + public Optional getUnits() { return units; } @@ -144,7 +144,7 @@ public Optional getAmount() { * */ @JsonProperty("request_type") - public Optional getRequestType() { + public Optional getRequestType() { return requestType; } @@ -230,15 +230,15 @@ public static final class Builder { private Optional approver = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional employeeNote = Optional.empty(); - private Optional units = Optional.empty(); + private Optional units = Optional.empty(); private Optional amount = Optional.empty(); - private Optional requestType = Optional.empty(); + private Optional requestType = Optional.empty(); private Optional startTime = Optional.empty(); @@ -291,12 +291,12 @@ public Builder approver(TimeOffRequestApprover approver) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(TimeOffRequestStatus status) { + public Builder status(TimeOffStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -313,12 +313,12 @@ public Builder employeeNote(String employeeNote) { } @JsonSetter(value = "units", nulls = Nulls.SKIP) - public Builder units(Optional units) { + public Builder units(Optional units) { this.units = units; return this; } - public Builder units(TimeOffRequestUnits units) { + public Builder units(UnitsEnum units) { this.units = Optional.ofNullable(units); return this; } @@ -335,12 +335,12 @@ public Builder amount(Double amount) { } @JsonSetter(value = "request_type", nulls = Nulls.SKIP) - public Builder requestType(Optional requestType) { + public Builder requestType(Optional requestType) { this.requestType = requestType; return this; } - public Builder requestType(TimeOffRequestRequestType requestType) { + public Builder requestType(RequestTypeEnum requestType) { this.requestType = Optional.ofNullable(requestType); return this; } diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestApprover.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestApprover.java index e134fb203..08b52c91c 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestApprover.java +++ b/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestApprover.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public TimeOffRequestApprover deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TimeOffRequestApprover deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestEmployee.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestEmployee.java index cccbb60ea..7b69b9a7d 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestEmployee.java +++ b/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public TimeOffRequestEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TimeOffRequestEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestRequestType.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestRequestType.java deleted file mode 100644 index 350839ecc..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestRequestType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TimeOffRequestRequestType.Deserializer.class) -public final class TimeOffRequestRequestType { - private final Object value; - - private final int type; - - private TimeOffRequestRequestType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RequestTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TimeOffRequestRequestType && equalTo((TimeOffRequestRequestType) other); - } - - private boolean equalTo(TimeOffRequestRequestType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TimeOffRequestRequestType of(RequestTypeEnum value) { - return new TimeOffRequestRequestType(value, 0); - } - - public static TimeOffRequestRequestType of(String value) { - return new TimeOffRequestRequestType(value, 1); - } - - public interface Visitor { - T visit(RequestTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TimeOffRequestRequestType.class); - } - - @java.lang.Override - public TimeOffRequestRequestType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RequestTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestStatus.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestStatus.java deleted file mode 100644 index c2a26027c..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TimeOffRequestStatus.Deserializer.class) -public final class TimeOffRequestStatus { - private final Object value; - - private final int type; - - private TimeOffRequestStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TimeOffStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TimeOffRequestStatus && equalTo((TimeOffRequestStatus) other); - } - - private boolean equalTo(TimeOffRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TimeOffRequestStatus of(TimeOffStatusEnum value) { - return new TimeOffRequestStatus(value, 0); - } - - public static TimeOffRequestStatus of(String value) { - return new TimeOffRequestStatus(value, 1); - } - - public interface Visitor { - T visit(TimeOffStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TimeOffRequestStatus.class); - } - - @java.lang.Override - public TimeOffRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TimeOffStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestType.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestType.java deleted file mode 100644 index ee613f78c..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TimeOffRequestType.Deserializer.class) -public final class TimeOffRequestType { - private final Object value; - - private final int type; - - private TimeOffRequestType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RequestTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TimeOffRequestType && equalTo((TimeOffRequestType) other); - } - - private boolean equalTo(TimeOffRequestType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TimeOffRequestType of(RequestTypeEnum value) { - return new TimeOffRequestType(value, 0); - } - - public static TimeOffRequestType of(String value) { - return new TimeOffRequestType(value, 1); - } - - public interface Visitor { - T visit(RequestTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TimeOffRequestType.class); - } - - @java.lang.Override - public TimeOffRequestType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RequestTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestUnits.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestUnits.java deleted file mode 100644 index 9f8ee4fc1..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffRequestUnits.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TimeOffRequestUnits.Deserializer.class) -public final class TimeOffRequestUnits { - private final Object value; - - private final int type; - - private TimeOffRequestUnits(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((UnitsEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TimeOffRequestUnits && equalTo((TimeOffRequestUnits) other); - } - - private boolean equalTo(TimeOffRequestUnits other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TimeOffRequestUnits of(UnitsEnum value) { - return new TimeOffRequestUnits(value, 0); - } - - public static TimeOffRequestUnits of(String value) { - return new TimeOffRequestUnits(value, 1); - } - - public interface Visitor { - T visit(UnitsEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TimeOffRequestUnits.class); - } - - @java.lang.Override - public TimeOffRequestUnits deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, UnitsEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffStatus.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffStatus.java deleted file mode 100644 index f7fd5e889..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TimeOffStatus.Deserializer.class) -public final class TimeOffStatus { - private final Object value; - - private final int type; - - private TimeOffStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TimeOffStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TimeOffStatus && equalTo((TimeOffStatus) other); - } - - private boolean equalTo(TimeOffStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TimeOffStatus of(TimeOffStatusEnum value) { - return new TimeOffStatus(value, 0); - } - - public static TimeOffStatus of(String value) { - return new TimeOffStatus(value, 1); - } - - public interface Visitor { - T visit(TimeOffStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TimeOffStatus.class); - } - - @java.lang.Override - public TimeOffStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TimeOffStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/TimeOffUnits.java b/src/main/java/com/merge/api/resources/hris/types/TimeOffUnits.java deleted file mode 100644 index 08762d319..000000000 --- a/src/main/java/com/merge/api/resources/hris/types/TimeOffUnits.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.hris.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TimeOffUnits.Deserializer.class) -public final class TimeOffUnits { - private final Object value; - - private final int type; - - private TimeOffUnits(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((UnitsEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TimeOffUnits && equalTo((TimeOffUnits) other); - } - - private boolean equalTo(TimeOffUnits other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TimeOffUnits of(UnitsEnum value) { - return new TimeOffUnits(value, 0); - } - - public static TimeOffUnits of(String value) { - return new TimeOffUnits(value, 1); - } - - public interface Visitor { - T visit(UnitsEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TimeOffUnits.class); - } - - @java.lang.Override - public TimeOffUnits deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, UnitsEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/hris/types/TimesheetEntryEmployee.java b/src/main/java/com/merge/api/resources/hris/types/TimesheetEntryEmployee.java index 00eea930d..6e585f112 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TimesheetEntryEmployee.java +++ b/src/main/java/com/merge/api/resources/hris/types/TimesheetEntryEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public TimesheetEntryEmployee deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TimesheetEntryEmployee deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/hris/types/TimesheetEntryRequestEmployee.java b/src/main/java/com/merge/api/resources/hris/types/TimesheetEntryRequestEmployee.java index ceddef7a2..24a652924 100644 --- a/src/main/java/com/merge/api/resources/hris/types/TimesheetEntryRequestEmployee.java +++ b/src/main/java/com/merge/api/resources/hris/types/TimesheetEntryRequestEmployee.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializerWebhookReceiver objects. + */ + public CompletableFuture>> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create( + WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/hris/webhookreceivers/AsyncWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/hris/webhookreceivers/AsyncWebhookReceiversClient.java new file mode 100644 index 000000000..435b5cef1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/webhookreceivers/AsyncWebhookReceiversClient.java @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.webhookreceivers; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.WebhookReceiver; +import com.merge.api.resources.hris.webhookreceivers.requests.WebhookReceiverRequest; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncWebhookReceiversClient { + protected final ClientOptions clientOptions; + + private final AsyncRawWebhookReceiversClient rawClient; + + public AsyncWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawWebhookReceiversClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/hris/webhookreceivers/RawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/hris/webhookreceivers/RawWebhookReceiversClient.java new file mode 100644 index 000000000..d56bf9ce2 --- /dev/null +++ b/src/main/java/com/merge/api/resources/hris/webhookreceivers/RawWebhookReceiversClient.java @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.hris.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.hris.types.WebhookReceiver; +import com.merge.api.resources.hris.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public RawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("hris/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/hris/webhookreceivers/WebhookReceiversClient.java b/src/main/java/com/merge/api/resources/hris/webhookreceivers/WebhookReceiversClient.java index 004fabb86..ce2b00de6 100644 --- a/src/main/java/com/merge/api/resources/hris/webhookreceivers/WebhookReceiversClient.java +++ b/src/main/java/com/merge/api/resources/hris/webhookreceivers/WebhookReceiversClient.java @@ -3,120 +3,54 @@ */ package com.merge.api.resources.hris.webhookreceivers; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.hris.types.WebhookReceiver; import com.merge.api.resources.hris.webhookreceivers.requests.WebhookReceiverRequest; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class WebhookReceiversClient { protected final ClientOptions clientOptions; + private final RawWebhookReceiversClient rawClient; + public WebhookReceiversClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawWebhookReceiversClient withRawResponse() { + return this.rawClient; } /** * Returns a list of WebhookReceiver objects. */ public List list() { - return list(null); + return this.rawClient.list().body(); } /** * Returns a list of WebhookReceiver objects. */ public List list(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/webhook-receivers") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(requestOptions).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("hris/v1/webhook-receivers") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/AsyncTicketingClient.java b/src/main/java/com/merge/api/resources/ticketing/AsyncTicketingClient.java new file mode 100644 index 000000000..d6bdbe878 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/AsyncTicketingClient.java @@ -0,0 +1,240 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.Suppliers; +import com.merge.api.resources.ticketing.accountdetails.AsyncAccountDetailsClient; +import com.merge.api.resources.ticketing.accounts.AsyncAccountsClient; +import com.merge.api.resources.ticketing.accounttoken.AsyncAccountTokenClient; +import com.merge.api.resources.ticketing.asyncpassthrough.AsyncAsyncPassthroughClient; +import com.merge.api.resources.ticketing.attachments.AsyncAttachmentsClient; +import com.merge.api.resources.ticketing.audittrail.AsyncAuditTrailClient; +import com.merge.api.resources.ticketing.availableactions.AsyncAvailableActionsClient; +import com.merge.api.resources.ticketing.collections.AsyncCollectionsClient; +import com.merge.api.resources.ticketing.comments.AsyncCommentsClient; +import com.merge.api.resources.ticketing.contacts.AsyncContactsClient; +import com.merge.api.resources.ticketing.deleteaccount.AsyncDeleteAccountClient; +import com.merge.api.resources.ticketing.fieldmapping.AsyncFieldMappingClient; +import com.merge.api.resources.ticketing.forceresync.AsyncForceResyncClient; +import com.merge.api.resources.ticketing.generatekey.AsyncGenerateKeyClient; +import com.merge.api.resources.ticketing.issues.AsyncIssuesClient; +import com.merge.api.resources.ticketing.linkedaccounts.AsyncLinkedAccountsClient; +import com.merge.api.resources.ticketing.linktoken.AsyncLinkTokenClient; +import com.merge.api.resources.ticketing.passthrough.AsyncPassthroughClient; +import com.merge.api.resources.ticketing.projects.AsyncProjectsClient; +import com.merge.api.resources.ticketing.regeneratekey.AsyncRegenerateKeyClient; +import com.merge.api.resources.ticketing.roles.AsyncRolesClient; +import com.merge.api.resources.ticketing.scopes.AsyncScopesClient; +import com.merge.api.resources.ticketing.syncstatus.AsyncSyncStatusClient; +import com.merge.api.resources.ticketing.tags.AsyncTagsClient; +import com.merge.api.resources.ticketing.teams.AsyncTeamsClient; +import com.merge.api.resources.ticketing.tickets.AsyncTicketsClient; +import com.merge.api.resources.ticketing.users.AsyncUsersClient; +import com.merge.api.resources.ticketing.webhookreceivers.AsyncWebhookReceiversClient; +import java.util.function.Supplier; + +public class AsyncTicketingClient { + protected final ClientOptions clientOptions; + + protected final Supplier accountDetailsClient; + + protected final Supplier accountTokenClient; + + protected final Supplier accountsClient; + + protected final Supplier asyncPassthroughClient; + + protected final Supplier attachmentsClient; + + protected final Supplier auditTrailClient; + + protected final Supplier availableActionsClient; + + protected final Supplier collectionsClient; + + protected final Supplier commentsClient; + + protected final Supplier contactsClient; + + protected final Supplier scopesClient; + + protected final Supplier deleteAccountClient; + + protected final Supplier fieldMappingClient; + + protected final Supplier generateKeyClient; + + protected final Supplier issuesClient; + + protected final Supplier linkTokenClient; + + protected final Supplier linkedAccountsClient; + + protected final Supplier passthroughClient; + + protected final Supplier projectsClient; + + protected final Supplier regenerateKeyClient; + + protected final Supplier rolesClient; + + protected final Supplier syncStatusClient; + + protected final Supplier forceResyncClient; + + protected final Supplier tagsClient; + + protected final Supplier teamsClient; + + protected final Supplier ticketsClient; + + protected final Supplier usersClient; + + protected final Supplier webhookReceiversClient; + + public AsyncTicketingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.accountDetailsClient = Suppliers.memoize(() -> new AsyncAccountDetailsClient(clientOptions)); + this.accountTokenClient = Suppliers.memoize(() -> new AsyncAccountTokenClient(clientOptions)); + this.accountsClient = Suppliers.memoize(() -> new AsyncAccountsClient(clientOptions)); + this.asyncPassthroughClient = Suppliers.memoize(() -> new AsyncAsyncPassthroughClient(clientOptions)); + this.attachmentsClient = Suppliers.memoize(() -> new AsyncAttachmentsClient(clientOptions)); + this.auditTrailClient = Suppliers.memoize(() -> new AsyncAuditTrailClient(clientOptions)); + this.availableActionsClient = Suppliers.memoize(() -> new AsyncAvailableActionsClient(clientOptions)); + this.collectionsClient = Suppliers.memoize(() -> new AsyncCollectionsClient(clientOptions)); + this.commentsClient = Suppliers.memoize(() -> new AsyncCommentsClient(clientOptions)); + this.contactsClient = Suppliers.memoize(() -> new AsyncContactsClient(clientOptions)); + this.scopesClient = Suppliers.memoize(() -> new AsyncScopesClient(clientOptions)); + this.deleteAccountClient = Suppliers.memoize(() -> new AsyncDeleteAccountClient(clientOptions)); + this.fieldMappingClient = Suppliers.memoize(() -> new AsyncFieldMappingClient(clientOptions)); + this.generateKeyClient = Suppliers.memoize(() -> new AsyncGenerateKeyClient(clientOptions)); + this.issuesClient = Suppliers.memoize(() -> new AsyncIssuesClient(clientOptions)); + this.linkTokenClient = Suppliers.memoize(() -> new AsyncLinkTokenClient(clientOptions)); + this.linkedAccountsClient = Suppliers.memoize(() -> new AsyncLinkedAccountsClient(clientOptions)); + this.passthroughClient = Suppliers.memoize(() -> new AsyncPassthroughClient(clientOptions)); + this.projectsClient = Suppliers.memoize(() -> new AsyncProjectsClient(clientOptions)); + this.regenerateKeyClient = Suppliers.memoize(() -> new AsyncRegenerateKeyClient(clientOptions)); + this.rolesClient = Suppliers.memoize(() -> new AsyncRolesClient(clientOptions)); + this.syncStatusClient = Suppliers.memoize(() -> new AsyncSyncStatusClient(clientOptions)); + this.forceResyncClient = Suppliers.memoize(() -> new AsyncForceResyncClient(clientOptions)); + this.tagsClient = Suppliers.memoize(() -> new AsyncTagsClient(clientOptions)); + this.teamsClient = Suppliers.memoize(() -> new AsyncTeamsClient(clientOptions)); + this.ticketsClient = Suppliers.memoize(() -> new AsyncTicketsClient(clientOptions)); + this.usersClient = Suppliers.memoize(() -> new AsyncUsersClient(clientOptions)); + this.webhookReceiversClient = Suppliers.memoize(() -> new AsyncWebhookReceiversClient(clientOptions)); + } + + public AsyncAccountDetailsClient accountDetails() { + return this.accountDetailsClient.get(); + } + + public AsyncAccountTokenClient accountToken() { + return this.accountTokenClient.get(); + } + + public AsyncAccountsClient accounts() { + return this.accountsClient.get(); + } + + public AsyncAsyncPassthroughClient asyncPassthrough() { + return this.asyncPassthroughClient.get(); + } + + public AsyncAttachmentsClient attachments() { + return this.attachmentsClient.get(); + } + + public AsyncAuditTrailClient auditTrail() { + return this.auditTrailClient.get(); + } + + public AsyncAvailableActionsClient availableActions() { + return this.availableActionsClient.get(); + } + + public AsyncCollectionsClient collections() { + return this.collectionsClient.get(); + } + + public AsyncCommentsClient comments() { + return this.commentsClient.get(); + } + + public AsyncContactsClient contacts() { + return this.contactsClient.get(); + } + + public AsyncScopesClient scopes() { + return this.scopesClient.get(); + } + + public AsyncDeleteAccountClient deleteAccount() { + return this.deleteAccountClient.get(); + } + + public AsyncFieldMappingClient fieldMapping() { + return this.fieldMappingClient.get(); + } + + public AsyncGenerateKeyClient generateKey() { + return this.generateKeyClient.get(); + } + + public AsyncIssuesClient issues() { + return this.issuesClient.get(); + } + + public AsyncLinkTokenClient linkToken() { + return this.linkTokenClient.get(); + } + + public AsyncLinkedAccountsClient linkedAccounts() { + return this.linkedAccountsClient.get(); + } + + public AsyncPassthroughClient passthrough() { + return this.passthroughClient.get(); + } + + public AsyncProjectsClient projects() { + return this.projectsClient.get(); + } + + public AsyncRegenerateKeyClient regenerateKey() { + return this.regenerateKeyClient.get(); + } + + public AsyncRolesClient roles() { + return this.rolesClient.get(); + } + + public AsyncSyncStatusClient syncStatus() { + return this.syncStatusClient.get(); + } + + public AsyncForceResyncClient forceResync() { + return this.forceResyncClient.get(); + } + + public AsyncTagsClient tags() { + return this.tagsClient.get(); + } + + public AsyncTeamsClient teams() { + return this.teamsClient.get(); + } + + public AsyncTicketsClient tickets() { + return this.ticketsClient.get(); + } + + public AsyncUsersClient users() { + return this.usersClient.get(); + } + + public AsyncWebhookReceiversClient webhookReceivers() { + return this.webhookReceiversClient.get(); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/accountdetails/AccountDetailsClient.java b/src/main/java/com/merge/api/resources/ticketing/accountdetails/AccountDetailsClient.java index da38a1772..34fd4e72c 100644 --- a/src/main/java/com/merge/api/resources/ticketing/accountdetails/AccountDetailsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/accountdetails/AccountDetailsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.ticketing.accountdetails; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.types.AccountDetails; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountDetailsClient { protected final ClientOptions clientOptions; + private final RawAccountDetailsClient rawClient; + public AccountDetailsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountDetailsClient withRawResponse() { + return this.rawClient; } /** * Get details for a linked account. */ public AccountDetails retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Get details for a linked account. */ public AccountDetails retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/account-details") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/accountdetails/AsyncAccountDetailsClient.java b/src/main/java/com/merge/api/resources/ticketing/accountdetails/AsyncAccountDetailsClient.java new file mode 100644 index 000000000..b604678c3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/accountdetails/AsyncAccountDetailsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.accountdetails; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.AccountDetails; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountDetailsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountDetailsClient rawClient; + + public AsyncAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountDetailsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountDetailsClient withRawResponse() { + return this.rawClient; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/accountdetails/AsyncRawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/ticketing/accountdetails/AsyncRawAccountDetailsClient.java new file mode 100644 index 000000000..af7996cf6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/accountdetails/AsyncRawAccountDetailsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.AccountDetails; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/accountdetails/RawAccountDetailsClient.java b/src/main/java/com/merge/api/resources/ticketing/accountdetails/RawAccountDetailsClient.java new file mode 100644 index 000000000..a8cd5e586 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/accountdetails/RawAccountDetailsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.accountdetails; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.AccountDetails; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountDetailsClient { + protected final ClientOptions clientOptions; + + public RawAccountDetailsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Get details for a linked account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/account-details") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountDetails.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/accounts/AccountsClient.java b/src/main/java/com/merge/api/resources/ticketing/accounts/AccountsClient.java index 64385b9bc..b68b8b5ab 100644 --- a/src/main/java/com/merge/api/resources/ticketing/accounts/AccountsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/accounts/AccountsClient.java @@ -3,164 +3,69 @@ */ package com.merge.api.resources.ticketing.accounts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.accounts.requests.AccountsListRequest; import com.merge.api.resources.ticketing.accounts.requests.AccountsRetrieveRequest; import com.merge.api.resources.ticketing.types.Account; import com.merge.api.resources.ticketing.types.PaginatedAccountList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountsClient { protected final ClientOptions clientOptions; + private final RawAccountsClient rawClient; + public AccountsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Account objects. */ public PaginatedAccountList list() { - return list(AccountsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Account objects. */ public PaginatedAccountList list(AccountsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Account objects. */ public PaginatedAccountList list(AccountsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/accounts"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns an Account object with the given id. */ public Account retrieve(String id) { - return retrieve(id, AccountsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Account object with the given id. */ public Account retrieve(String id, AccountsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Account object with the given id. */ public Account retrieve(String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/accounts") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/accounts/AsyncAccountsClient.java b/src/main/java/com/merge/api/resources/ticketing/accounts/AsyncAccountsClient.java new file mode 100644 index 000000000..ca44c5334 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/accounts/AsyncAccountsClient.java @@ -0,0 +1,73 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.accounts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.accounts.requests.AccountsListRequest; +import com.merge.api.resources.ticketing.accounts.requests.AccountsRetrieveRequest; +import com.merge.api.resources.ticketing.types.Account; +import com.merge.api.resources.ticketing.types.PaginatedAccountList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountsClient rawClient; + + public AsyncAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture list(AccountsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture list(AccountsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture retrieve(String id, AccountsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture retrieve( + String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/accounts/AsyncRawAccountsClient.java b/src/main/java/com/merge/api/resources/ticketing/accounts/AsyncRawAccountsClient.java new file mode 100644 index 000000000..93983889c --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/accounts/AsyncRawAccountsClient.java @@ -0,0 +1,229 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.accounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.accounts.requests.AccountsListRequest; +import com.merge.api.resources.ticketing.accounts.requests.AccountsRetrieveRequest; +import com.merge.api.resources.ticketing.types.Account; +import com.merge.api.resources.ticketing.types.PaginatedAccountList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture> list() { + return list(AccountsListRequest.builder().build()); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture> list(AccountsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Account objects. + */ + public CompletableFuture> list( + AccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/accounts"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, AccountsRetrieveRequest.builder().build()); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture> retrieve(String id, AccountsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Account object with the given id. + */ + public CompletableFuture> retrieve( + String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/accounts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/accounts/RawAccountsClient.java b/src/main/java/com/merge/api/resources/ticketing/accounts/RawAccountsClient.java new file mode 100644 index 000000000..0b5c4ebcd --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/accounts/RawAccountsClient.java @@ -0,0 +1,198 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.accounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.accounts.requests.AccountsListRequest; +import com.merge.api.resources.ticketing.accounts.requests.AccountsRetrieveRequest; +import com.merge.api.resources.ticketing.types.Account; +import com.merge.api.resources.ticketing.types.PaginatedAccountList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountsClient { + protected final ClientOptions clientOptions; + + public RawAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Account objects. + */ + public MergeApiHttpResponse list() { + return list(AccountsListRequest.builder().build()); + } + + /** + * Returns a list of Account objects. + */ + public MergeApiHttpResponse list(AccountsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Account objects. + */ + public MergeApiHttpResponse list(AccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/accounts"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAccountList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Account object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, AccountsRetrieveRequest.builder().build()); + } + + /** + * Returns an Account object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, AccountsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Account object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, AccountsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/accounts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Account.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/accounts/requests/AccountsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/accounts/requests/AccountsRetrieveRequest.java index 279a7d031..a3c7cf05b 100644 --- a/src/main/java/com/merge/api/resources/ticketing/accounts/requests/AccountsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/accounts/requests/AccountsRetrieveRequest.java @@ -22,10 +22,16 @@ public final class AccountsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private AccountsRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private AccountsRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(AccountsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(AccountsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public AccountsRetrieveRequest build() { - return new AccountsRetrieveRequest(includeRemoteData, additionalProperties); + return new AccountsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/accounttoken/AccountTokenClient.java b/src/main/java/com/merge/api/resources/ticketing/accounttoken/AccountTokenClient.java index 50d365fc5..efc0165fc 100644 --- a/src/main/java/com/merge/api/resources/ticketing/accounttoken/AccountTokenClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/accounttoken/AccountTokenClient.java @@ -3,66 +3,38 @@ */ package com.merge.api.resources.ticketing.accounttoken; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.types.AccountToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AccountTokenClient { protected final ClientOptions clientOptions; + private final RawAccountTokenClient rawClient; + public AccountTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAccountTokenClient withRawResponse() { + return this.rawClient; } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken) { - return retrieve(publicToken, null); + return this.rawClient.retrieve(publicToken).body(); } /** * Returns the account token for the end user with the provided public token. */ public AccountToken retrieve(String publicToken, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/account-token") - .addPathSegment(publicToken) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(publicToken, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/accounttoken/AsyncAccountTokenClient.java b/src/main/java/com/merge/api/resources/ticketing/accounttoken/AsyncAccountTokenClient.java new file mode 100644 index 000000000..0e172b6b1 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/accounttoken/AsyncAccountTokenClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.accounttoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.AccountToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncAccountTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAccountTokenClient rawClient; + + public AsyncAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAccountTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAccountTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken) { + return this.rawClient.retrieve(publicToken).thenApply(response -> response.body()); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture retrieve(String publicToken, RequestOptions requestOptions) { + return this.rawClient.retrieve(publicToken, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/accounttoken/AsyncRawAccountTokenClient.java b/src/main/java/com/merge/api/resources/ticketing/accounttoken/AsyncRawAccountTokenClient.java new file mode 100644 index 000000000..249eb8852 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/accounttoken/AsyncRawAccountTokenClient.java @@ -0,0 +1,90 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.AccountToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAccountTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public CompletableFuture> retrieve( + String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/accounttoken/RawAccountTokenClient.java b/src/main/java/com/merge/api/resources/ticketing/accounttoken/RawAccountTokenClient.java new file mode 100644 index 000000000..554b91551 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/accounttoken/RawAccountTokenClient.java @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.accounttoken; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.AccountToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAccountTokenClient { + protected final ClientOptions clientOptions; + + public RawAccountTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken) { + return retrieve(publicToken, null); + } + + /** + * Returns the account token for the end user with the provided public token. + */ + public MergeApiHttpResponse retrieve(String publicToken, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/account-token") + .addPathSegment(publicToken) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AccountToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/AsyncAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/AsyncAsyncPassthroughClient.java new file mode 100644 index 000000000..c0428e62e --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/AsyncAsyncPassthroughClient.java @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.asyncpassthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.ticketing.types.AsyncPassthroughReciept; +import com.merge.api.resources.ticketing.types.DataPassthroughRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAsyncPassthroughClient rawClient; + + public AsyncAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAsyncPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create( + DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve(String asyncPassthroughReceiptId) { + return this.rawClient.retrieve(asyncPassthroughReceiptId).thenApply(response -> response.body()); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/AsyncPassthroughClient.java index e7dc575c6..0d667feb2 100644 --- a/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/AsyncPassthroughClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/AsyncPassthroughClient.java @@ -3,119 +3,56 @@ */ package com.merge.api.resources.ticketing.asyncpassthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; import com.merge.api.resources.ticketing.types.AsyncPassthroughReciept; import com.merge.api.resources.ticketing.types.DataPassthroughRequest; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AsyncPassthroughClient { protected final ClientOptions clientOptions; + private final RawAsyncPassthroughClient rawClient; + public AsyncPassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAsyncPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAsyncPassthroughClient withRawResponse() { + return this.rawClient; } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Asynchronously pull data from an endpoint not currently supported by Merge. */ public AsyncPassthroughReciept create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/async-passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId) { - return retrieve(asyncPassthroughReceiptId, null); + return this.rawClient.retrieve(asyncPassthroughReceiptId).body(); } /** * Retrieves data from earlier async-passthrough POST request */ public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/async-passthrough") - .addPathSegment(asyncPassthroughReceiptId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), AsyncPassthroughRetrieveResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .retrieve(asyncPassthroughReceiptId, requestOptions) + .body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/AsyncRawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/AsyncRawAsyncPassthroughClient.java new file mode 100644 index 000000000..eb517aaa6 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/AsyncRawAsyncPassthroughClient.java @@ -0,0 +1,163 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.ticketing.types.AsyncPassthroughReciept; +import com.merge.api.resources.ticketing.types.DataPassthroughRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughReciept.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public CompletableFuture> retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/RawAsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/RawAsyncPassthroughClient.java new file mode 100644 index 000000000..b254a0228 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/RawAsyncPassthroughClient.java @@ -0,0 +1,131 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.asyncpassthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.asyncpassthrough.types.AsyncPassthroughRetrieveResponse; +import com.merge.api.resources.ticketing.types.AsyncPassthroughReciept; +import com.merge.api.resources.ticketing.types.DataPassthroughRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAsyncPassthroughClient { + protected final ClientOptions clientOptions; + + public RawAsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Asynchronously pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/async-passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AsyncPassthroughReciept.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve(String asyncPassthroughReceiptId) { + return retrieve(asyncPassthroughReceiptId, null); + } + + /** + * Retrieves data from earlier async-passthrough POST request + */ + public MergeApiHttpResponse retrieve( + String asyncPassthroughReceiptId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/async-passthrough") + .addPathSegment(asyncPassthroughReceiptId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), AsyncPassthroughRetrieveResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java b/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java index b3ad1c8b3..6bcb8cd8d 100644 --- a/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java +++ b/src/main/java/com/merge/api/resources/ticketing/asyncpassthrough/types/AsyncPassthroughRetrieveResponse.java @@ -30,6 +30,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((RemoteResponse) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializerAttachment objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Attachment objects. + */ + public CompletableFuture list(AttachmentsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Attachment objects. + */ + public CompletableFuture list( + AttachmentsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates an Attachment object with the given values. + */ + public CompletableFuture create(TicketingAttachmentEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates an Attachment object with the given values. + */ + public CompletableFuture create( + TicketingAttachmentEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture retrieve(String id, AttachmentsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture retrieve( + String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture downloadRetrieve(String id) { + return this.rawClient.downloadRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture downloadRetrieve(String id, AttachmentsDownloadRetrieveRequest request) { + return this.rawClient.downloadRetrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture downloadRetrieve( + String id, AttachmentsDownloadRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.downloadRetrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for TicketingAttachment POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for TicketingAttachment POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/attachments/AsyncRawAttachmentsClient.java b/src/main/java/com/merge/api/resources/ticketing/attachments/AsyncRawAttachmentsClient.java new file mode 100644 index 000000000..5374c19ec --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/attachments/AsyncRawAttachmentsClient.java @@ -0,0 +1,469 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.attachments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.core.ResponseBodyInputStream; +import com.merge.api.resources.ticketing.attachments.requests.AttachmentsDownloadRetrieveRequest; +import com.merge.api.resources.ticketing.attachments.requests.AttachmentsListRequest; +import com.merge.api.resources.ticketing.attachments.requests.AttachmentsRetrieveRequest; +import com.merge.api.resources.ticketing.attachments.requests.TicketingAttachmentEndpointRequest; +import com.merge.api.resources.ticketing.types.Attachment; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedAttachmentList; +import com.merge.api.resources.ticketing.types.TicketingAttachmentResponse; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAttachmentsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAttachmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Attachment objects. + */ + public CompletableFuture> list() { + return list(AttachmentsListRequest.builder().build()); + } + + /** + * Returns a list of Attachment objects. + */ + public CompletableFuture> list(AttachmentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Attachment objects. + */ + public CompletableFuture> list( + AttachmentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/attachments"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_created_after", + request.getRemoteCreatedAfter().get().toString(), + false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTicketId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ticket_id", request.getTicketId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAttachmentList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates an Attachment object with the given values. + */ + public CompletableFuture> create( + TicketingAttachmentEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Attachment object with the given values. + */ + public CompletableFuture> create( + TicketingAttachmentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/attachments"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), TicketingAttachmentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, AttachmentsRetrieveRequest.builder().build()); + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture> retrieve(String id, AttachmentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Attachment object with the given id. + */ + public CompletableFuture> retrieve( + String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/attachments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Attachment.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture> downloadRetrieve(String id) { + return downloadRetrieve(id, AttachmentsDownloadRetrieveRequest.builder().build()); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture> downloadRetrieve( + String id, AttachmentsDownloadRetrieveRequest request) { + return downloadRetrieve(id, request, null); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public CompletableFuture> downloadRetrieve( + String id, AttachmentsDownloadRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/attachments") + .addPathSegment(id) + .addPathSegments("download"); + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getMimeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "mime_type", request.getMimeType().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(new ResponseBodyInputStream(response), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for TicketingAttachment POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for TicketingAttachment POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/attachments/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/attachments/AttachmentsClient.java b/src/main/java/com/merge/api/resources/ticketing/attachments/AttachmentsClient.java index 8c1dfe696..b5b2f7ce3 100644 --- a/src/main/java/com/merge/api/resources/ticketing/attachments/AttachmentsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/attachments/AttachmentsClient.java @@ -3,13 +3,8 @@ */ package com.merge.api.resources.ticketing.attachments; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; -import com.merge.api.core.ResponseBodyInputStream; import com.merge.api.resources.ticketing.attachments.requests.AttachmentsDownloadRetrieveRequest; import com.merge.api.resources.ticketing.attachments.requests.AttachmentsListRequest; import com.merge.api.resources.ticketing.attachments.requests.AttachmentsRetrieveRequest; @@ -18,126 +13,51 @@ import com.merge.api.resources.ticketing.types.MetaResponse; import com.merge.api.resources.ticketing.types.PaginatedAttachmentList; import com.merge.api.resources.ticketing.types.TicketingAttachmentResponse; -import java.io.IOException; import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AttachmentsClient { protected final ClientOptions clientOptions; + private final RawAttachmentsClient rawClient; + public AttachmentsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAttachmentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAttachmentsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Attachment objects. */ public PaginatedAttachmentList list() { - return list(AttachmentsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Attachment objects. */ public PaginatedAttachmentList list(AttachmentsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Attachment objects. */ public PaginatedAttachmentList list(AttachmentsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/attachments"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "remote_created_after", - request.getRemoteCreatedAfter().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getTicketId().isPresent()) { - httpUrl.addQueryParameter("ticket_id", request.getTicketId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAttachmentList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates an Attachment object with the given values. */ public TicketingAttachmentResponse create(TicketingAttachmentEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** @@ -145,118 +65,42 @@ public TicketingAttachmentResponse create(TicketingAttachmentEndpointRequest req */ public TicketingAttachmentResponse create( TicketingAttachmentEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/attachments"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketingAttachmentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns an Attachment object with the given id. */ public Attachment retrieve(String id) { - return retrieve(id, AttachmentsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns an Attachment object with the given id. */ public Attachment retrieve(String id, AttachmentsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns an Attachment object with the given id. */ public Attachment retrieve(String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/attachments") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Attachment.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns the File content with the given id as a stream of bytes. */ public InputStream downloadRetrieve(String id) { - return downloadRetrieve(id, AttachmentsDownloadRetrieveRequest.builder().build()); + return this.rawClient.downloadRetrieve(id).body(); } /** * Returns the File content with the given id as a stream of bytes. */ public InputStream downloadRetrieve(String id, AttachmentsDownloadRetrieveRequest request) { - return downloadRetrieve(id, request, null); + return this.rawClient.downloadRetrieve(id, request).body(); } /** @@ -264,78 +108,20 @@ public InputStream downloadRetrieve(String id, AttachmentsDownloadRetrieveReques */ public InputStream downloadRetrieve( String id, AttachmentsDownloadRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/attachments") - .addPathSegment(id) - .addPathSegments("download"); - if (request.getMimeType().isPresent()) { - httpUrl.addQueryParameter("mime_type", request.getMimeType().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try { - Response response = client.newCall(okhttpRequest).execute(); - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new ResponseBodyInputStream(response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.downloadRetrieve(id, request, requestOptions).body(); } /** * Returns metadata for TicketingAttachment POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for TicketingAttachment POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/attachments/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/attachments/RawAttachmentsClient.java b/src/main/java/com/merge/api/resources/ticketing/attachments/RawAttachmentsClient.java new file mode 100644 index 000000000..86070266a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/attachments/RawAttachmentsClient.java @@ -0,0 +1,394 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.attachments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.core.ResponseBodyInputStream; +import com.merge.api.resources.ticketing.attachments.requests.AttachmentsDownloadRetrieveRequest; +import com.merge.api.resources.ticketing.attachments.requests.AttachmentsListRequest; +import com.merge.api.resources.ticketing.attachments.requests.AttachmentsRetrieveRequest; +import com.merge.api.resources.ticketing.attachments.requests.TicketingAttachmentEndpointRequest; +import com.merge.api.resources.ticketing.types.Attachment; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedAttachmentList; +import com.merge.api.resources.ticketing.types.TicketingAttachmentResponse; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAttachmentsClient { + protected final ClientOptions clientOptions; + + public RawAttachmentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Attachment objects. + */ + public MergeApiHttpResponse list() { + return list(AttachmentsListRequest.builder().build()); + } + + /** + * Returns a list of Attachment objects. + */ + public MergeApiHttpResponse list(AttachmentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Attachment objects. + */ + public MergeApiHttpResponse list( + AttachmentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/attachments"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_created_after", + request.getRemoteCreatedAfter().get().toString(), + false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTicketId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ticket_id", request.getTicketId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAttachmentList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates an Attachment object with the given values. + */ + public MergeApiHttpResponse create(TicketingAttachmentEndpointRequest request) { + return create(request, null); + } + + /** + * Creates an Attachment object with the given values. + */ + public MergeApiHttpResponse create( + TicketingAttachmentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/attachments"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketingAttachmentResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns an Attachment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, AttachmentsRetrieveRequest.builder().build()); + } + + /** + * Returns an Attachment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, AttachmentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns an Attachment object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, AttachmentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/attachments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Attachment.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public MergeApiHttpResponse downloadRetrieve(String id) { + return downloadRetrieve(id, AttachmentsDownloadRetrieveRequest.builder().build()); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public MergeApiHttpResponse downloadRetrieve(String id, AttachmentsDownloadRetrieveRequest request) { + return downloadRetrieve(id, request, null); + } + + /** + * Returns the File content with the given id as a stream of bytes. + */ + public MergeApiHttpResponse downloadRetrieve( + String id, AttachmentsDownloadRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/attachments") + .addPathSegment(id) + .addPathSegments("download"); + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getMimeType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "mime_type", request.getMimeType().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try { + Response response = client.newCall(okhttpRequest).execute(); + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(new ResponseBodyInputStream(response), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for TicketingAttachment POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for TicketingAttachment POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/attachments/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsDownloadRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsDownloadRetrieveRequest.java index a9e397e51..75d381e02 100644 --- a/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsDownloadRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsDownloadRetrieveRequest.java @@ -20,15 +20,27 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AttachmentsDownloadRetrieveRequest.Builder.class) public final class AttachmentsDownloadRetrieveRequest { + private final Optional includeShellData; + private final Optional mimeType; private final Map additionalProperties; - private AttachmentsDownloadRetrieveRequest(Optional mimeType, Map additionalProperties) { + private AttachmentsDownloadRetrieveRequest( + Optional includeShellData, Optional mimeType, Map additionalProperties) { + this.includeShellData = includeShellData; this.mimeType = mimeType; this.additionalProperties = additionalProperties; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return If provided, specifies the export format of the file to be downloaded. For information on supported export formats, please refer to our <a href='https://help.merge.dev/en/articles/8615316-file-export-and-download-specification' target='_blank'>export format help center article</a>. */ @@ -50,12 +62,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(AttachmentsDownloadRetrieveRequest other) { - return mimeType.equals(other.mimeType); + return includeShellData.equals(other.includeShellData) && mimeType.equals(other.mimeType); } @java.lang.Override public int hashCode() { - return Objects.hash(this.mimeType); + return Objects.hash(this.includeShellData, this.mimeType); } @java.lang.Override @@ -69,6 +81,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional includeShellData = Optional.empty(); + private Optional mimeType = Optional.empty(); @JsonAnySetter @@ -77,10 +91,22 @@ public static final class Builder { private Builder() {} public Builder from(AttachmentsDownloadRetrieveRequest other) { + includeShellData(other.getIncludeShellData()); mimeType(other.getMimeType()); return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "mime_type", nulls = Nulls.SKIP) public Builder mimeType(Optional mimeType) { this.mimeType = mimeType; @@ -93,7 +119,7 @@ public Builder mimeType(String mimeType) { } public AttachmentsDownloadRetrieveRequest build() { - return new AttachmentsDownloadRetrieveRequest(mimeType, additionalProperties); + return new AttachmentsDownloadRetrieveRequest(includeShellData, mimeType, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsListRequest.java b/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsListRequest.java index e499cfee7..d110090de 100644 --- a/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsListRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,14 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AttachmentsListRequest.Builder.class) public final class AttachmentsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -50,10 +52,10 @@ public final class AttachmentsListRequest { private final Map additionalProperties; private AttachmentsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -64,10 +66,10 @@ private AttachmentsListRequest( Optional remoteId, Optional ticketId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -80,6 +82,14 @@ private AttachmentsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -104,14 +114,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -196,10 +198,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(AttachmentsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -214,10 +216,10 @@ private boolean equalTo(AttachmentsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -240,14 +242,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -272,10 +274,10 @@ public static final class Builder { private Builder() {} public Builder from(AttachmentsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -288,6 +290,22 @@ public Builder from(AttachmentsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -321,17 +339,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -433,10 +440,10 @@ public Builder ticketId(String ticketId) { public AttachmentsListRequest build() { return new AttachmentsListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsRetrieveRequest.java index a403f2974..d086bf5d2 100644 --- a/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/attachments/requests/AttachmentsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = AttachmentsRetrieveRequest.Builder.class) public final class AttachmentsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private AttachmentsRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private AttachmentsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(AttachmentsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(AttachmentsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public AttachmentsRetrieveRequest build() { - return new AttachmentsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new AttachmentsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/audittrail/AsyncAuditTrailClient.java b/src/main/java/com/merge/api/resources/ticketing/audittrail/AsyncAuditTrailClient.java new file mode 100644 index 000000000..ed2694e45 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/audittrail/AsyncAuditTrailClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.audittrail; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.ticketing.types.PaginatedAuditLogEventList; +import java.util.concurrent.CompletableFuture; + +public class AsyncAuditTrailClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAuditTrailClient rawClient; + + public AsyncAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAuditTrailClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAuditTrailClient withRawResponse() { + return this.rawClient; + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list(AuditTrailListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture list( + AuditTrailListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/audittrail/AsyncRawAuditTrailClient.java b/src/main/java/com/merge/api/resources/ticketing/audittrail/AsyncRawAuditTrailClient.java new file mode 100644 index 000000000..d407e070b --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/audittrail/AsyncRawAuditTrailClient.java @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.ticketing.types.PaginatedAuditLogEventList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAuditTrailClient { + protected final ClientOptions clientOptions; + + public AsyncRawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public CompletableFuture> list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAuditLogEventList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/audittrail/AuditTrailClient.java b/src/main/java/com/merge/api/resources/ticketing/audittrail/AuditTrailClient.java index 05c1114a1..8d416cf0a 100644 --- a/src/main/java/com/merge/api/resources/ticketing/audittrail/AuditTrailClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/audittrail/AuditTrailClient.java @@ -3,90 +3,46 @@ */ package com.merge.api.resources.ticketing.audittrail; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.audittrail.requests.AuditTrailListRequest; import com.merge.api.resources.ticketing.types.PaginatedAuditLogEventList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AuditTrailClient { protected final ClientOptions clientOptions; + private final RawAuditTrailClient rawClient; + public AuditTrailClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAuditTrailClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAuditTrailClient withRawResponse() { + return this.rawClient; } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list() { - return list(AuditTrailListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets a list of audit trail events. */ public PaginatedAuditLogEventList list(AuditTrailListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/audit-trail"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEventType().isPresent()) { - httpUrl.addQueryParameter("event_type", request.getEventType().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getUserEmail().isPresent()) { - httpUrl.addQueryParameter("user_email", request.getUserEmail().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/audittrail/RawAuditTrailClient.java b/src/main/java/com/merge/api/resources/ticketing/audittrail/RawAuditTrailClient.java new file mode 100644 index 000000000..732f90c06 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/audittrail/RawAuditTrailClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.audittrail; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.audittrail.requests.AuditTrailListRequest; +import com.merge.api.resources.ticketing.types.PaginatedAuditLogEventList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAuditTrailClient { + protected final ClientOptions clientOptions; + + public RawAuditTrailClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list() { + return list(AuditTrailListRequest.builder().build()); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list(AuditTrailListRequest request) { + return list(request, null); + } + + /** + * Gets a list of audit trail events. + */ + public MergeApiHttpResponse list( + AuditTrailListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/audit-trail"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEventType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "event_type", request.getEventType().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getUserEmail().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "user_email", request.getUserEmail().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedAuditLogEventList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/audittrail/requests/AuditTrailListRequest.java b/src/main/java/com/merge/api/resources/ticketing/audittrail/requests/AuditTrailListRequest.java index 696f09e89..ace5585bd 100644 --- a/src/main/java/com/merge/api/resources/ticketing/audittrail/requests/AuditTrailListRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/audittrail/requests/AuditTrailListRequest.java @@ -68,7 +68,7 @@ public Optional getEndDate() { } /** - * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED + * @return If included, will only include events with the given event type. Possible values include: CREATED_REMOTE_PRODUCTION_API_KEY, DELETED_REMOTE_PRODUCTION_API_KEY, CREATED_TEST_API_KEY, DELETED_TEST_API_KEY, REGENERATED_PRODUCTION_API_KEY, INVITED_USER, TWO_FACTOR_AUTH_ENABLED, TWO_FACTOR_AUTH_DISABLED, DELETED_LINKED_ACCOUNT, DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT, CREATED_DESTINATION, DELETED_DESTINATION, CHANGED_DESTINATION, CHANGED_SCOPES, CHANGED_PERSONAL_INFORMATION, CHANGED_ORGANIZATION_SETTINGS, ENABLED_INTEGRATION, DISABLED_INTEGRATION, ENABLED_CATEGORY, DISABLED_CATEGORY, CHANGED_PASSWORD, RESET_PASSWORD, ENABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, ENABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, DISABLED_REDACT_UNMAPPED_DATA_FOR_ORGANIZATION, DISABLED_REDACT_UNMAPPED_DATA_FOR_LINKED_ACCOUNT, CREATED_INTEGRATION_WIDE_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_FIELD_MAPPING, CHANGED_INTEGRATION_WIDE_FIELD_MAPPING, CHANGED_LINKED_ACCOUNT_FIELD_MAPPING, DELETED_INTEGRATION_WIDE_FIELD_MAPPING, DELETED_LINKED_ACCOUNT_FIELD_MAPPING, CREATED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, CHANGED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, DELETED_LINKED_ACCOUNT_COMMON_MODEL_OVERRIDE, FORCED_LINKED_ACCOUNT_RESYNC, MUTED_ISSUE, GENERATED_MAGIC_LINK, ENABLED_MERGE_WEBHOOK, DISABLED_MERGE_WEBHOOK, MERGE_WEBHOOK_TARGET_CHANGED, END_USER_CREDENTIALS_ACCESSED */ @JsonProperty("event_type") public Optional getEventType() { diff --git a/src/main/java/com/merge/api/resources/ticketing/availableactions/AsyncAvailableActionsClient.java b/src/main/java/com/merge/api/resources/ticketing/availableactions/AsyncAvailableActionsClient.java new file mode 100644 index 000000000..6d623eb4e --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/availableactions/AsyncAvailableActionsClient.java @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.availableactions; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.AvailableActions; +import java.util.concurrent.CompletableFuture; + +public class AsyncAvailableActionsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawAvailableActionsClient rawClient; + + public AsyncAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawAvailableActionsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve() { + return this.rawClient.retrieve().thenApply(response -> response.body()); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture retrieve(RequestOptions requestOptions) { + return this.rawClient.retrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/availableactions/AsyncRawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/ticketing/availableactions/AsyncRawAvailableActionsClient.java new file mode 100644 index 000000000..1b8c04a23 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/availableactions/AsyncRawAvailableActionsClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.AvailableActions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public AsyncRawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public CompletableFuture> retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/availableactions/AvailableActionsClient.java b/src/main/java/com/merge/api/resources/ticketing/availableactions/AvailableActionsClient.java index 9ce48f8ab..87b6313a0 100644 --- a/src/main/java/com/merge/api/resources/ticketing/availableactions/AvailableActionsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/availableactions/AvailableActionsClient.java @@ -3,65 +3,38 @@ */ package com.merge.api.resources.ticketing.availableactions; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.types.AvailableActions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class AvailableActionsClient { protected final ClientOptions clientOptions; + private final RawAvailableActionsClient rawClient; + public AvailableActionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawAvailableActionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawAvailableActionsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve() { - return retrieve(null); + return this.rawClient.retrieve().body(); } /** * Returns a list of models and actions available for an account. */ public AvailableActions retrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/available-actions") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/availableactions/RawAvailableActionsClient.java b/src/main/java/com/merge/api/resources/ticketing/availableactions/RawAvailableActionsClient.java new file mode 100644 index 000000000..a0a7cde09 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/availableactions/RawAvailableActionsClient.java @@ -0,0 +1,70 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.availableactions; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.AvailableActions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawAvailableActionsClient { + protected final ClientOptions clientOptions; + + public RawAvailableActionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve() { + return retrieve(null); + } + + /** + * Returns a list of models and actions available for an account. + */ + public MergeApiHttpResponse retrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/available-actions") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AvailableActions.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/collections/AsyncCollectionsClient.java b/src/main/java/com/merge/api/resources/ticketing/collections/AsyncCollectionsClient.java new file mode 100644 index 000000000..c8ae80412 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/collections/AsyncCollectionsClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.collections; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.collections.requests.CollectionsListRequest; +import com.merge.api.resources.ticketing.collections.requests.CollectionsRetrieveRequest; +import com.merge.api.resources.ticketing.collections.requests.CollectionsViewersListRequest; +import com.merge.api.resources.ticketing.types.Collection; +import com.merge.api.resources.ticketing.types.PaginatedCollectionList; +import com.merge.api.resources.ticketing.types.PaginatedViewerList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCollectionsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCollectionsClient rawClient; + + public AsyncCollectionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCollectionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCollectionsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Collection objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Collection objects. + */ + public CompletableFuture list(CollectionsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Collection objects. + */ + public CompletableFuture list( + CollectionsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public CompletableFuture viewersList(String collectionId) { + return this.rawClient.viewersList(collectionId).thenApply(response -> response.body()); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public CompletableFuture viewersList( + String collectionId, CollectionsViewersListRequest request) { + return this.rawClient.viewersList(collectionId, request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public CompletableFuture viewersList( + String collectionId, CollectionsViewersListRequest request, RequestOptions requestOptions) { + return this.rawClient.viewersList(collectionId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Collection object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Collection object with the given id. + */ + public CompletableFuture retrieve(String id, CollectionsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Collection object with the given id. + */ + public CompletableFuture retrieve( + String id, CollectionsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/collections/AsyncRawCollectionsClient.java b/src/main/java/com/merge/api/resources/ticketing/collections/AsyncRawCollectionsClient.java new file mode 100644 index 000000000..469302896 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/collections/AsyncRawCollectionsClient.java @@ -0,0 +1,368 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.collections; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.collections.requests.CollectionsListRequest; +import com.merge.api.resources.ticketing.collections.requests.CollectionsRetrieveRequest; +import com.merge.api.resources.ticketing.collections.requests.CollectionsViewersListRequest; +import com.merge.api.resources.ticketing.types.Collection; +import com.merge.api.resources.ticketing.types.PaginatedCollectionList; +import com.merge.api.resources.ticketing.types.PaginatedViewerList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCollectionsClient { + protected final ClientOptions clientOptions; + + public AsyncRawCollectionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Collection objects. + */ + public CompletableFuture> list() { + return list(CollectionsListRequest.builder().build()); + } + + /** + * Returns a list of Collection objects. + */ + public CompletableFuture> list(CollectionsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Collection objects. + */ + public CompletableFuture> list( + CollectionsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/collections"); + if (request.getCollectionType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "collection_type", request.getCollectionType().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getParentCollectionId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "parent_collection_id", + request.getParentCollectionId().get(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedCollectionList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public CompletableFuture> viewersList(String collectionId) { + return viewersList(collectionId, CollectionsViewersListRequest.builder().build()); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public CompletableFuture> viewersList( + String collectionId, CollectionsViewersListRequest request) { + return viewersList(collectionId, request, null); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public CompletableFuture> viewersList( + String collectionId, CollectionsViewersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/collections") + .addPathSegment(collectionId) + .addPathSegments("viewers"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedViewerList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Collection object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, CollectionsRetrieveRequest.builder().build()); + } + + /** + * Returns a Collection object with the given id. + */ + public CompletableFuture> retrieve(String id, CollectionsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Collection object with the given id. + */ + public CompletableFuture> retrieve( + String id, CollectionsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/collections") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/collections/CollectionsClient.java b/src/main/java/com/merge/api/resources/ticketing/collections/CollectionsClient.java index 2a06f63ba..003264a79 100644 --- a/src/main/java/com/merge/api/resources/ticketing/collections/CollectionsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/collections/CollectionsClient.java @@ -3,192 +3,93 @@ */ package com.merge.api.resources.ticketing.collections; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.collections.requests.CollectionsListRequest; import com.merge.api.resources.ticketing.collections.requests.CollectionsRetrieveRequest; +import com.merge.api.resources.ticketing.collections.requests.CollectionsViewersListRequest; import com.merge.api.resources.ticketing.types.Collection; import com.merge.api.resources.ticketing.types.PaginatedCollectionList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; +import com.merge.api.resources.ticketing.types.PaginatedViewerList; public class CollectionsClient { protected final ClientOptions clientOptions; + private final RawCollectionsClient rawClient; + public CollectionsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCollectionsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCollectionsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Collection objects. */ public PaginatedCollectionList list() { - return list(CollectionsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Collection objects. */ public PaginatedCollectionList list(CollectionsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Collection objects. */ public PaginatedCollectionList list(CollectionsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/collections"); - if (request.getCollectionType().isPresent()) { - httpUrl.addQueryParameter( - "collection_type", request.getCollectionType().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getParentCollectionId().isPresent()) { - httpUrl.addQueryParameter( - "parent_collection_id", request.getParentCollectionId().get()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCollectionList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public PaginatedViewerList viewersList(String collectionId) { + return this.rawClient.viewersList(collectionId).body(); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public PaginatedViewerList viewersList(String collectionId, CollectionsViewersListRequest request) { + return this.rawClient.viewersList(collectionId, request).body(); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public PaginatedViewerList viewersList( + String collectionId, CollectionsViewersListRequest request, RequestOptions requestOptions) { + return this.rawClient.viewersList(collectionId, request, requestOptions).body(); } /** * Returns a Collection object with the given id. */ public Collection retrieve(String id) { - return retrieve(id, CollectionsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Collection object with the given id. */ public Collection retrieve(String id, CollectionsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Collection object with the given id. */ public Collection retrieve(String id, CollectionsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/collections") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter("remote_fields", request.getRemoteFields().get()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/collections/RawCollectionsClient.java b/src/main/java/com/merge/api/resources/ticketing/collections/RawCollectionsClient.java new file mode 100644 index 000000000..77f565676 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/collections/RawCollectionsClient.java @@ -0,0 +1,323 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.collections; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.collections.requests.CollectionsListRequest; +import com.merge.api.resources.ticketing.collections.requests.CollectionsRetrieveRequest; +import com.merge.api.resources.ticketing.collections.requests.CollectionsViewersListRequest; +import com.merge.api.resources.ticketing.types.Collection; +import com.merge.api.resources.ticketing.types.PaginatedCollectionList; +import com.merge.api.resources.ticketing.types.PaginatedViewerList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCollectionsClient { + protected final ClientOptions clientOptions; + + public RawCollectionsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Collection objects. + */ + public MergeApiHttpResponse list() { + return list(CollectionsListRequest.builder().build()); + } + + /** + * Returns a list of Collection objects. + */ + public MergeApiHttpResponse list(CollectionsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Collection objects. + */ + public MergeApiHttpResponse list( + CollectionsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/collections"); + if (request.getCollectionType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "collection_type", request.getCollectionType().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getParentCollectionId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "parent_collection_id", + request.getParentCollectionId().get(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCollectionList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public MergeApiHttpResponse viewersList(String collectionId) { + return viewersList(collectionId, CollectionsViewersListRequest.builder().build()); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public MergeApiHttpResponse viewersList( + String collectionId, CollectionsViewersListRequest request) { + return viewersList(collectionId, request, null); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Collection with the given id. Learn more. + */ + public MergeApiHttpResponse viewersList( + String collectionId, CollectionsViewersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/collections") + .addPathSegment(collectionId) + .addPathSegments("viewers"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedViewerList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Collection object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, CollectionsRetrieveRequest.builder().build()); + } + + /** + * Returns a Collection object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, CollectionsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Collection object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, CollectionsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/collections") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "show_enum_origins", request.getShowEnumOrigins().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Collection.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsListRequest.java b/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsListRequest.java index 2fe591021..705b6e895 100644 --- a/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsListRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsListRequest.java @@ -12,9 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ticketing.collections.types.CollectionsListRequestExpand; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +23,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CollectionsListRequest.Builder.class) public final class CollectionsListRequest { + private final Optional> expand; + private final Optional collectionType; private final Optional createdAfter; @@ -30,8 +33,6 @@ public final class CollectionsListRequest { private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -55,11 +56,11 @@ public final class CollectionsListRequest { private final Map additionalProperties; private CollectionsListRequest( + Optional> expand, Optional collectionType, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -71,11 +72,11 @@ private CollectionsListRequest( Optional remoteId, Optional showEnumOrigins, Map additionalProperties) { + this.expand = expand; this.collectionType = collectionType; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -89,6 +90,14 @@ private CollectionsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return collections of the given type. */ @@ -121,14 +130,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -221,11 +222,11 @@ public Map getAdditionalProperties() { } private boolean equalTo(CollectionsListRequest other) { - return collectionType.equals(other.collectionType) + return expand.equals(other.expand) + && collectionType.equals(other.collectionType) && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -241,11 +242,11 @@ private boolean equalTo(CollectionsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.collectionType, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -269,6 +270,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional collectionType = Optional.empty(); private Optional createdAfter = Optional.empty(); @@ -277,8 +280,6 @@ public static final class Builder { private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -305,11 +306,11 @@ public static final class Builder { private Builder() {} public Builder from(CollectionsListRequest other) { + expand(other.getExpand()); collectionType(other.getCollectionType()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -323,6 +324,22 @@ public Builder from(CollectionsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "collection_type", nulls = Nulls.SKIP) public Builder collectionType(Optional collectionType) { this.collectionType = collectionType; @@ -367,17 +384,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(CollectionsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -490,11 +496,11 @@ public Builder showEnumOrigins(String showEnumOrigins) { public CollectionsListRequest build() { return new CollectionsListRequest( + expand, collectionType, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsRetrieveRequest.java index d55afc21e..7132e0a66 100644 --- a/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsRetrieveRequest.java @@ -12,8 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ticketing.collections.types.CollectionsRetrieveRequestExpand; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,10 +22,12 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CollectionsRetrieveRequest.Builder.class) public final class CollectionsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -32,13 +35,15 @@ public final class CollectionsRetrieveRequest { private final Map additionalProperties; private CollectionsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -48,7 +53,7 @@ private CollectionsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -60,6 +65,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -90,13 +103,15 @@ public Map getAdditionalProperties() { private boolean equalTo(CollectionsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData, this.remoteFields, this.showEnumOrigins); + return Objects.hash( + this.expand, this.includeRemoteData, this.includeShellData, this.remoteFields, this.showEnumOrigins); } @java.lang.Override @@ -110,10 +125,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -126,22 +143,28 @@ private Builder() {} public Builder from(CollectionsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(CollectionsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -153,6 +176,17 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -177,7 +211,7 @@ public Builder showEnumOrigins(String showEnumOrigins) { public CollectionsRetrieveRequest build() { return new CollectionsRetrieveRequest( - expand, includeRemoteData, remoteFields, showEnumOrigins, additionalProperties); + expand, includeRemoteData, includeShellData, remoteFields, showEnumOrigins, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsViewersListRequest.java b/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsViewersListRequest.java new file mode 100644 index 000000000..d716fbaf3 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/collections/requests/CollectionsViewersListRequest.java @@ -0,0 +1,256 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.collections.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.merge.api.core.ObjectMappers; +import com.merge.api.resources.ticketing.collections.types.CollectionsViewersListRequestExpandItem; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = CollectionsViewersListRequest.Builder.class) +public final class CollectionsViewersListRequest { + private final Optional> expand; + + private final Optional cursor; + + private final Optional includeDeletedData; + + private final Optional includeRemoteData; + + private final Optional includeShellData; + + private final Optional pageSize; + + private final Map additionalProperties; + + private CollectionsViewersListRequest( + Optional> expand, + Optional cursor, + Optional includeDeletedData, + Optional includeRemoteData, + Optional includeShellData, + Optional pageSize, + Map additionalProperties) { + this.expand = expand; + this.cursor = cursor; + this.includeDeletedData = includeDeletedData; + this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; + this.pageSize = pageSize; + this.additionalProperties = additionalProperties; + } + + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + + /** + * @return The pagination cursor value. + */ + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; + } + + /** + * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. + */ + @JsonProperty("include_deleted_data") + public Optional getIncludeDeletedData() { + return includeDeletedData; + } + + /** + * @return Whether to include the original data Merge fetched from the third-party to produce these models. + */ + @JsonProperty("include_remote_data") + public Optional getIncludeRemoteData() { + return includeRemoteData; + } + + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + + /** + * @return Number of results to return per page. + */ + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof CollectionsViewersListRequest && equalTo((CollectionsViewersListRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(CollectionsViewersListRequest other) { + return expand.equals(other.expand) + && cursor.equals(other.cursor) + && includeDeletedData.equals(other.includeDeletedData) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData) + && pageSize.equals(other.pageSize); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.expand, + this.cursor, + this.includeDeletedData, + this.includeRemoteData, + this.includeShellData, + this.pageSize); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional> expand = Optional.empty(); + + private Optional cursor = Optional.empty(); + + private Optional includeDeletedData = Optional.empty(); + + private Optional includeRemoteData = Optional.empty(); + + private Optional includeShellData = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(CollectionsViewersListRequest other) { + expand(other.getExpand()); + cursor(other.getCursor()); + includeDeletedData(other.getIncludeDeletedData()); + includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); + pageSize(other.getPageSize()); + return this; + } + + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(CollectionsViewersListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); + return this; + } + + @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) + public Builder includeDeletedData(Optional includeDeletedData) { + this.includeDeletedData = includeDeletedData; + return this; + } + + public Builder includeDeletedData(Boolean includeDeletedData) { + this.includeDeletedData = Optional.ofNullable(includeDeletedData); + return this; + } + + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) + public Builder includeRemoteData(Optional includeRemoteData) { + this.includeRemoteData = includeRemoteData; + return this; + } + + public Builder includeRemoteData(Boolean includeRemoteData) { + this.includeRemoteData = Optional.ofNullable(includeRemoteData); + return this; + } + + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) + public Builder pageSize(Optional pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder pageSize(Integer pageSize) { + this.pageSize = Optional.ofNullable(pageSize); + return this; + } + + public CollectionsViewersListRequest build() { + return new CollectionsViewersListRequest( + expand, + cursor, + includeDeletedData, + includeRemoteData, + includeShellData, + pageSize, + additionalProperties); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/collections/types/CollectionsListRequestExpand.java b/src/main/java/com/merge/api/resources/ticketing/collections/types/CollectionsListRequestExpand.java deleted file mode 100644 index 0122fd5f0..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/collections/types/CollectionsListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.collections.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CollectionsListRequestExpand { - PARENT_COLLECTION("parent_collection"), - - TEAMS("teams"), - - TEAMS_PARENT_COLLECTION("teams,parent_collection"); - - private final String value; - - CollectionsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/collections/types/CollectionsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/ticketing/collections/types/CollectionsRetrieveRequestExpand.java deleted file mode 100644 index 9fd13b404..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/collections/types/CollectionsRetrieveRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.collections.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CollectionsRetrieveRequestExpand { - PARENT_COLLECTION("parent_collection"), - - TEAMS("teams"), - - TEAMS_PARENT_COLLECTION("teams,parent_collection"); - - private final String value; - - CollectionsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/collections/types/CollectionsViewersListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ticketing/collections/types/CollectionsViewersListRequestExpandItem.java new file mode 100644 index 000000000..6de6b8d59 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/collections/types/CollectionsViewersListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.collections.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CollectionsViewersListRequestExpandItem { + TEAM("team"), + + USER("user"); + + private final String value; + + CollectionsViewersListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/comments/AsyncCommentsClient.java b/src/main/java/com/merge/api/resources/ticketing/comments/AsyncCommentsClient.java new file mode 100644 index 000000000..f3bd63592 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/comments/AsyncCommentsClient.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.comments; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.comments.requests.CommentEndpointRequest; +import com.merge.api.resources.ticketing.comments.requests.CommentsListRequest; +import com.merge.api.resources.ticketing.comments.requests.CommentsRetrieveRequest; +import com.merge.api.resources.ticketing.types.Comment; +import com.merge.api.resources.ticketing.types.CommentResponse; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedCommentList; +import java.util.concurrent.CompletableFuture; + +public class AsyncCommentsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawCommentsClient rawClient; + + public AsyncCommentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawCommentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawCommentsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Comment objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Comment objects. + */ + public CompletableFuture list(CommentsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Comment objects. + */ + public CompletableFuture list(CommentsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Comment object with the given values. + */ + public CompletableFuture create(CommentEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Comment object with the given values. + */ + public CompletableFuture create(CommentEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Comment object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Comment object with the given id. + */ + public CompletableFuture retrieve(String id, CommentsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Comment object with the given id. + */ + public CompletableFuture retrieve( + String id, CommentsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Comment POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Comment POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/comments/AsyncRawCommentsClient.java b/src/main/java/com/merge/api/resources/ticketing/comments/AsyncRawCommentsClient.java new file mode 100644 index 000000000..2748561da --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/comments/AsyncRawCommentsClient.java @@ -0,0 +1,386 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.comments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.comments.requests.CommentEndpointRequest; +import com.merge.api.resources.ticketing.comments.requests.CommentsListRequest; +import com.merge.api.resources.ticketing.comments.requests.CommentsRetrieveRequest; +import com.merge.api.resources.ticketing.types.Comment; +import com.merge.api.resources.ticketing.types.CommentResponse; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedCommentList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawCommentsClient { + protected final ClientOptions clientOptions; + + public AsyncRawCommentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Comment objects. + */ + public CompletableFuture> list() { + return list(CommentsListRequest.builder().build()); + } + + /** + * Returns a list of Comment objects. + */ + public CompletableFuture> list(CommentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Comment objects. + */ + public CompletableFuture> list( + CommentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/comments"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_created_after", + request.getRemoteCreatedAfter().get().toString(), + false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTicketId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ticket_id", request.getTicketId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCommentList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Comment object with the given values. + */ + public CompletableFuture> create(CommentEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Comment object with the given values. + */ + public CompletableFuture> create( + CommentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/comments"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommentResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Comment object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, CommentsRetrieveRequest.builder().build()); + } + + /** + * Returns a Comment object with the given id. + */ + public CompletableFuture> retrieve(String id, CommentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Comment object with the given id. + */ + public CompletableFuture> retrieve( + String id, CommentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/comments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Comment.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Comment POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Comment POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/comments/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/comments/CommentsClient.java b/src/main/java/com/merge/api/resources/ticketing/comments/CommentsClient.java index c446df77b..9c51bc7f1 100644 --- a/src/main/java/com/merge/api/resources/ticketing/comments/CommentsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/comments/CommentsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.ticketing.comments; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.comments.requests.CommentEndpointRequest; import com.merge.api.resources.ticketing.comments.requests.CommentsListRequest; @@ -16,269 +12,91 @@ import com.merge.api.resources.ticketing.types.CommentResponse; import com.merge.api.resources.ticketing.types.MetaResponse; import com.merge.api.resources.ticketing.types.PaginatedCommentList; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class CommentsClient { protected final ClientOptions clientOptions; + private final RawCommentsClient rawClient; + public CommentsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawCommentsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawCommentsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Comment objects. */ public PaginatedCommentList list() { - return list(CommentsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Comment objects. */ public PaginatedCommentList list(CommentsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Comment objects. */ public PaginatedCommentList list(CommentsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/comments"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "remote_created_after", - request.getRemoteCreatedAfter().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getTicketId().isPresent()) { - httpUrl.addQueryParameter("ticket_id", request.getTicketId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCommentList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Comment object with the given values. */ public CommentResponse create(CommentEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Comment object with the given values. */ public CommentResponse create(CommentEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/comments"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Comment object with the given id. */ public Comment retrieve(String id) { - return retrieve(id, CommentsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Comment object with the given id. */ public Comment retrieve(String id, CommentsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Comment object with the given id. */ public Comment retrieve(String id, CommentsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/comments") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Comment.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for Comment POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Comment POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/comments/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/comments/RawCommentsClient.java b/src/main/java/com/merge/api/resources/ticketing/comments/RawCommentsClient.java new file mode 100644 index 000000000..7ffe2c955 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/comments/RawCommentsClient.java @@ -0,0 +1,326 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.comments; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.comments.requests.CommentEndpointRequest; +import com.merge.api.resources.ticketing.comments.requests.CommentsListRequest; +import com.merge.api.resources.ticketing.comments.requests.CommentsRetrieveRequest; +import com.merge.api.resources.ticketing.types.Comment; +import com.merge.api.resources.ticketing.types.CommentResponse; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedCommentList; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawCommentsClient { + protected final ClientOptions clientOptions; + + public RawCommentsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Comment objects. + */ + public MergeApiHttpResponse list() { + return list(CommentsListRequest.builder().build()); + } + + /** + * Returns a list of Comment objects. + */ + public MergeApiHttpResponse list(CommentsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Comment objects. + */ + public MergeApiHttpResponse list(CommentsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/comments"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_created_after", + request.getRemoteCreatedAfter().get().toString(), + false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTicketId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ticket_id", request.getTicketId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedCommentList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Comment object with the given values. + */ + public MergeApiHttpResponse create(CommentEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Comment object with the given values. + */ + public MergeApiHttpResponse create(CommentEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/comments"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommentResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Comment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, CommentsRetrieveRequest.builder().build()); + } + + /** + * Returns a Comment object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, CommentsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Comment object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, CommentsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/comments") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Comment.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Comment POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Comment POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/comments/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/comments/requests/CommentsListRequest.java b/src/main/java/com/merge/api/resources/ticketing/comments/requests/CommentsListRequest.java index f6618f46c..1c1347ee0 100644 --- a/src/main/java/com/merge/api/resources/ticketing/comments/requests/CommentsListRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/comments/requests/CommentsListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ticketing.comments.types.CommentsListRequestExpand; +import com.merge.api.resources.ticketing.comments.types.CommentsListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,14 +24,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CommentsListRequest.Builder.class) public final class CommentsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -51,10 +53,10 @@ public final class CommentsListRequest { private final Map additionalProperties; private CommentsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -65,10 +67,10 @@ private CommentsListRequest( Optional remoteId, Optional ticketId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -81,6 +83,14 @@ private CommentsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -105,14 +115,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -197,10 +199,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(CommentsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -215,10 +217,10 @@ private boolean equalTo(CommentsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -241,14 +243,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -273,10 +275,10 @@ public static final class Builder { private Builder() {} public Builder from(CommentsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -289,6 +291,22 @@ public Builder from(CommentsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(CommentsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -322,17 +340,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(CommentsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -434,10 +441,10 @@ public Builder ticketId(String ticketId) { public CommentsListRequest build() { return new CommentsListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ticketing/comments/requests/CommentsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/comments/requests/CommentsRetrieveRequest.java index 5ecf9eebd..59266a9b1 100644 --- a/src/main/java/com/merge/api/resources/ticketing/comments/requests/CommentsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/comments/requests/CommentsRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ticketing.comments.types.CommentsRetrieveRequestExpand; +import com.merge.api.resources.ticketing.comments.types.CommentsRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = CommentsRetrieveRequest.Builder.class) public final class CommentsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private CommentsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private CommentsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(CommentsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -83,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,20 +113,26 @@ private Builder() {} public Builder from(CommentsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(CommentsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(CommentsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -120,8 +144,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public CommentsRetrieveRequest build() { - return new CommentsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new CommentsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsListRequestExpand.java b/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsListRequestExpand.java deleted file mode 100644 index 1179d62c8..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsListRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.comments.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CommentsListRequestExpand { - CONTACT("contact"), - - CONTACT_TICKET("contact,ticket"), - - TICKET("ticket"), - - USER("user"), - - USER_CONTACT("user,contact"), - - USER_CONTACT_TICKET("user,contact,ticket"), - - USER_TICKET("user,ticket"); - - private final String value; - - CommentsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsListRequestExpandItem.java new file mode 100644 index 000000000..4475d430c --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsListRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.comments.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CommentsListRequestExpandItem { + CONTACT("contact"), + + TICKET("ticket"), + + USER("user"); + + private final String value; + + CommentsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsRetrieveRequestExpand.java deleted file mode 100644 index 8b3b01d4b..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsRetrieveRequestExpand.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.comments.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CommentsRetrieveRequestExpand { - CONTACT("contact"), - - CONTACT_TICKET("contact,ticket"), - - TICKET("ticket"), - - USER("user"), - - USER_CONTACT("user,contact"), - - USER_CONTACT_TICKET("user,contact,ticket"), - - USER_TICKET("user,ticket"); - - private final String value; - - CommentsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..cc3af0440 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/comments/types/CommentsRetrieveRequestExpandItem.java @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.comments.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum CommentsRetrieveRequestExpandItem { + CONTACT("contact"), + + TICKET("ticket"), + + USER("user"); + + private final String value; + + CommentsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/contacts/AsyncContactsClient.java b/src/main/java/com/merge/api/resources/ticketing/contacts/AsyncContactsClient.java new file mode 100644 index 000000000..aa816524f --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/contacts/AsyncContactsClient.java @@ -0,0 +1,105 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.contacts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.contacts.requests.ContactsListRequest; +import com.merge.api.resources.ticketing.contacts.requests.ContactsRetrieveRequest; +import com.merge.api.resources.ticketing.contacts.requests.TicketingContactEndpointRequest; +import com.merge.api.resources.ticketing.types.Contact; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedContactList; +import com.merge.api.resources.ticketing.types.TicketingContactResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncContactsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawContactsClient rawClient; + + public AsyncContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawContactsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawContactsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture list(ContactsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture list(ContactsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture create(TicketingContactEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture create( + TicketingContactEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture retrieve(String id, ContactsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture retrieve( + String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for TicketingContact POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for TicketingContact POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/contacts/AsyncRawContactsClient.java b/src/main/java/com/merge/api/resources/ticketing/contacts/AsyncRawContactsClient.java new file mode 100644 index 000000000..c5586dabb --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/contacts/AsyncRawContactsClient.java @@ -0,0 +1,377 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.contacts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.contacts.requests.ContactsListRequest; +import com.merge.api.resources.ticketing.contacts.requests.ContactsRetrieveRequest; +import com.merge.api.resources.ticketing.contacts.requests.TicketingContactEndpointRequest; +import com.merge.api.resources.ticketing.types.Contact; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedContactList; +import com.merge.api.resources.ticketing.types.TicketingContactResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawContactsClient { + protected final ClientOptions clientOptions; + + public AsyncRawContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture> list() { + return list(ContactsListRequest.builder().build()); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture> list(ContactsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Contact objects. + */ + public CompletableFuture> list( + ContactsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/contacts"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedContactList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture> create( + TicketingContactEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Contact object with the given values. + */ + public CompletableFuture> create( + TicketingContactEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/contacts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), TicketingContactResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, ContactsRetrieveRequest.builder().build()); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture> retrieve(String id, ContactsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Contact object with the given id. + */ + public CompletableFuture> retrieve( + String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/contacts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for TicketingContact POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for TicketingContact POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/contacts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/contacts/ContactsClient.java b/src/main/java/com/merge/api/resources/ticketing/contacts/ContactsClient.java index f9cb502d9..8ebb991ed 100644 --- a/src/main/java/com/merge/api/resources/ticketing/contacts/ContactsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/contacts/ContactsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.ticketing.contacts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.contacts.requests.ContactsListRequest; import com.merge.api.resources.ticketing.contacts.requests.ContactsRetrieveRequest; @@ -16,261 +12,91 @@ import com.merge.api.resources.ticketing.types.MetaResponse; import com.merge.api.resources.ticketing.types.PaginatedContactList; import com.merge.api.resources.ticketing.types.TicketingContactResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ContactsClient { protected final ClientOptions clientOptions; + private final RawContactsClient rawClient; + public ContactsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawContactsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawContactsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Contact objects. */ public PaginatedContactList list() { - return list(ContactsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Contact objects. */ public PaginatedContactList list(ContactsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Contact objects. */ public PaginatedContactList list(ContactsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/contacts"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedContactList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Contact object with the given values. */ public TicketingContactResponse create(TicketingContactEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Contact object with the given values. */ public TicketingContactResponse create(TicketingContactEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/contacts"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketingContactResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Contact object with the given id. */ public Contact retrieve(String id) { - return retrieve(id, ContactsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Contact object with the given id. */ public Contact retrieve(String id, ContactsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Contact object with the given id. */ public Contact retrieve(String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/contacts") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns metadata for TicketingContact POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for TicketingContact POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/contacts/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/contacts/RawContactsClient.java b/src/main/java/com/merge/api/resources/ticketing/contacts/RawContactsClient.java new file mode 100644 index 000000000..c1ae23eef --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/contacts/RawContactsClient.java @@ -0,0 +1,317 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.contacts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.contacts.requests.ContactsListRequest; +import com.merge.api.resources.ticketing.contacts.requests.ContactsRetrieveRequest; +import com.merge.api.resources.ticketing.contacts.requests.TicketingContactEndpointRequest; +import com.merge.api.resources.ticketing.types.Contact; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedContactList; +import com.merge.api.resources.ticketing.types.TicketingContactResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawContactsClient { + protected final ClientOptions clientOptions; + + public RawContactsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Contact objects. + */ + public MergeApiHttpResponse list() { + return list(ContactsListRequest.builder().build()); + } + + /** + * Returns a list of Contact objects. + */ + public MergeApiHttpResponse list(ContactsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Contact objects. + */ + public MergeApiHttpResponse list(ContactsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/contacts"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedContactList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Contact object with the given values. + */ + public MergeApiHttpResponse create(TicketingContactEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Contact object with the given values. + */ + public MergeApiHttpResponse create( + TicketingContactEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/contacts"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketingContactResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Contact object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, ContactsRetrieveRequest.builder().build()); + } + + /** + * Returns a Contact object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, ContactsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Contact object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, ContactsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/contacts") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Contact.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for TicketingContact POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for TicketingContact POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/contacts/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/contacts/requests/ContactsListRequest.java b/src/main/java/com/merge/api/resources/ticketing/contacts/requests/ContactsListRequest.java index 03b185839..e80fddc6a 100644 --- a/src/main/java/com/merge/api/resources/ticketing/contacts/requests/ContactsListRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/contacts/requests/ContactsListRequest.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,14 +23,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContactsListRequest.Builder.class) public final class ContactsListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; private final Optional cursor; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -46,10 +48,10 @@ public final class ContactsListRequest { private final Map additionalProperties; private ContactsListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -58,10 +60,10 @@ private ContactsListRequest( Optional pageSize, Optional remoteId, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -72,6 +74,14 @@ private ContactsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -96,14 +106,6 @@ public Optional getCursor() { return cursor; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -172,10 +174,10 @@ public Map getAdditionalProperties() { } private boolean equalTo(ContactsListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -188,10 +190,10 @@ private boolean equalTo(ContactsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -212,14 +214,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); private Optional cursor = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -240,10 +242,10 @@ public static final class Builder { private Builder() {} public Builder from(ContactsListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -254,6 +256,22 @@ public Builder from(ContactsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "created_after", nulls = Nulls.SKIP) public Builder createdAfter(Optional createdAfter) { this.createdAfter = createdAfter; @@ -287,17 +305,6 @@ public Builder cursor(String cursor) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(String expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -377,10 +384,10 @@ public Builder remoteId(String remoteId) { public ContactsListRequest build() { return new ContactsListRequest( + expand, createdAfter, createdBefore, cursor, - expand, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ticketing/contacts/requests/ContactsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/contacts/requests/ContactsRetrieveRequest.java index a3cdf3db4..c7ea51d3a 100644 --- a/src/main/java/com/merge/api/resources/ticketing/contacts/requests/ContactsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/contacts/requests/ContactsRetrieveRequest.java @@ -12,7 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -20,16 +22,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ContactsRetrieveRequest.Builder.class) public final class ContactsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private ContactsRetrieveRequest( - Optional expand, Optional includeRemoteData, Map additionalProperties) { + Optional> expand, + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,7 +45,7 @@ private ContactsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -49,6 +57,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -61,12 +77,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(ContactsRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -80,10 +98,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -92,20 +112,26 @@ private Builder() {} public Builder from(ContactsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(String expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(String expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -117,8 +143,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public ContactsRetrieveRequest build() { - return new ContactsRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new ContactsRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/deleteaccount/AsyncDeleteAccountClient.java b/src/main/java/com/merge/api/resources/ticketing/deleteaccount/AsyncDeleteAccountClient.java new file mode 100644 index 000000000..97dd359f0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/deleteaccount/AsyncDeleteAccountClient.java @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.deleteaccount; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import java.util.concurrent.CompletableFuture; + +public class AsyncDeleteAccountClient { + protected final ClientOptions clientOptions; + + private final AsyncRawDeleteAccountClient rawClient; + + public AsyncDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawDeleteAccountClient withRawResponse() { + return this.rawClient; + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete() { + return this.rawClient.delete().thenApply(response -> response.body()); + } + + /** + * Delete a linked account. + */ + public CompletableFuture delete(RequestOptions requestOptions) { + return this.rawClient.delete(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/deleteaccount/AsyncRawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/ticketing/deleteaccount/AsyncRawDeleteAccountClient.java new file mode 100644 index 000000000..92635eaef --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/deleteaccount/AsyncRawDeleteAccountClient.java @@ -0,0 +1,84 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public AsyncRawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public CompletableFuture> delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>(null, response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/deleteaccount/DeleteAccountClient.java b/src/main/java/com/merge/api/resources/ticketing/deleteaccount/DeleteAccountClient.java index 5f4a41a25..8f355c56f 100644 --- a/src/main/java/com/merge/api/resources/ticketing/deleteaccount/DeleteAccountClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/deleteaccount/DeleteAccountClient.java @@ -3,63 +3,37 @@ */ package com.merge.api.resources.ticketing.deleteaccount; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class DeleteAccountClient { protected final ClientOptions clientOptions; + private final RawDeleteAccountClient rawClient; + public DeleteAccountClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawDeleteAccountClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawDeleteAccountClient withRawResponse() { + return this.rawClient; } /** * Delete a linked account. */ public void delete() { - delete(null); + this.rawClient.delete().body(); } /** * Delete a linked account. */ public void delete(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/delete-account") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + this.rawClient.delete(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/deleteaccount/RawDeleteAccountClient.java b/src/main/java/com/merge/api/resources/ticketing/deleteaccount/RawDeleteAccountClient.java new file mode 100644 index 000000000..ecccbd58c --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/deleteaccount/RawDeleteAccountClient.java @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.deleteaccount; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawDeleteAccountClient { + protected final ClientOptions clientOptions; + + public RawDeleteAccountClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete() { + return delete(null); + } + + /** + * Delete a linked account. + */ + public MergeApiHttpResponse delete(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/delete-account") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>(null, response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/fieldmapping/AsyncFieldMappingClient.java b/src/main/java/com/merge/api/resources/ticketing/fieldmapping/AsyncFieldMappingClient.java new file mode 100644 index 000000000..81018b5cb --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/fieldmapping/AsyncFieldMappingClient.java @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.fieldmapping; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.ticketing.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.ticketing.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.ticketing.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.ticketing.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.ticketing.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.ticketing.types.FieldMappingInstanceResponse; +import com.merge.api.resources.ticketing.types.RemoteFieldApiResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncFieldMappingClient { + protected final ClientOptions clientOptions; + + private final AsyncRawFieldMappingClient rawClient; + + public AsyncFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawFieldMappingClient withRawResponse() { + return this.rawClient; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve() { + return this.rawClient.fieldMappingsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return this.rawClient.fieldMappingsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate(CreateFieldMappingRequest request) { + return this.rawClient.fieldMappingsCreate(request).thenApply(response -> response.body()); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient.fieldMappingsCreate(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy(String fieldMappingId) { + return this.rawClient.fieldMappingsDestroy(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate(String fieldMappingId) { + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .thenApply(response -> response.body()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve() { + return this.rawClient.remoteFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return this.rawClient.remoteFieldsRetrieve(request).thenApply(response -> response.body()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve() { + return this.rawClient.targetFieldsRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture targetFieldsRetrieve(RequestOptions requestOptions) { + return this.rawClient.targetFieldsRetrieve(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/fieldmapping/AsyncRawFieldMappingClient.java b/src/main/java/com/merge/api/resources/ticketing/fieldmapping/AsyncRawFieldMappingClient.java new file mode 100644 index 000000000..054a8ff5e --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/fieldmapping/AsyncRawFieldMappingClient.java @@ -0,0 +1,471 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.ticketing.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.ticketing.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.ticketing.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.ticketing.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.ticketing.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.ticketing.types.FieldMappingInstanceResponse; +import com.merge.api.resources.ticketing.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawFieldMappingClient { + protected final ClientOptions clientOptions; + + public AsyncRawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public CompletableFuture> fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public CompletableFuture> fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingInstanceResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public CompletableFuture> remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), RemoteFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public CompletableFuture> targetFieldsRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/fieldmapping/FieldMappingClient.java b/src/main/java/com/merge/api/resources/ticketing/fieldmapping/FieldMappingClient.java index 2e245fd2e..1cedebe0c 100644 --- a/src/main/java/com/merge/api/resources/ticketing/fieldmapping/FieldMappingClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/fieldmapping/FieldMappingClient.java @@ -3,12 +3,7 @@ */ package com.merge.api.resources.ticketing.fieldmapping; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.fieldmapping.requests.CreateFieldMappingRequest; import com.merge.api.resources.ticketing.fieldmapping.requests.FieldMappingsRetrieveRequest; @@ -18,36 +13,36 @@ import com.merge.api.resources.ticketing.types.FieldMappingApiInstanceResponse; import com.merge.api.resources.ticketing.types.FieldMappingInstanceResponse; import com.merge.api.resources.ticketing.types.RemoteFieldApiResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class FieldMappingClient { protected final ClientOptions clientOptions; + private final RawFieldMappingClient rawClient; + public FieldMappingClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawFieldMappingClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawFieldMappingClient withRawResponse() { + return this.rawClient; } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve() { - return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + return this.rawClient.fieldMappingsRetrieve().body(); } /** * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrieveRequest request) { - return fieldMappingsRetrieve(request, null); + return this.rawClient.fieldMappingsRetrieve(request).body(); } /** @@ -55,46 +50,14 @@ public FieldMappingApiInstanceResponse fieldMappingsRetrieve(FieldMappingsRetrie */ public FieldMappingApiInstanceResponse fieldMappingsRetrieve( FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), FieldMappingApiInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsRetrieve(request, requestOptions).body(); } /** * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingRequest request) { - return fieldMappingsCreate(request, null); + return this.rawClient.fieldMappingsCreate(request).body(); } /** @@ -102,102 +65,30 @@ public FieldMappingInstanceResponse fieldMappingsCreate(CreateFieldMappingReques */ public FieldMappingInstanceResponse fieldMappingsCreate( CreateFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/field-mappings"); - if (request.getExcludeRemoteFieldMetadata().isPresent()) { - httpUrl.addQueryParameter( - "exclude_remote_field_metadata", - request.getExcludeRemoteFieldMetadata().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("target_field_name", request.getTargetFieldName()); - properties.put("target_field_description", request.getTargetFieldDescription()); - properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); - properties.put("remote_method", request.getRemoteMethod()); - properties.put("remote_url_path", request.getRemoteUrlPath()); - properties.put("common_model_name", request.getCommonModelName()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.fieldMappingsCreate(request, requestOptions).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId) { - return fieldMappingsDestroy(fieldMappingId, null); + return this.rawClient.fieldMappingsDestroy(fieldMappingId).body(); } /** * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsDestroy(String fieldMappingId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsDestroy(fieldMappingId, requestOptions) + .body(); } /** * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappingId) { - return fieldMappingsPartialUpdate( - fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + return this.rawClient.fieldMappingsPartialUpdate(fieldMappingId).body(); } /** @@ -205,7 +96,9 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate(String fieldMappi */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request) { - return fieldMappingsPartialUpdate(fieldMappingId, request, null); + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request) + .body(); } /** @@ -213,56 +106,23 @@ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( */ public FieldMappingInstanceResponse fieldMappingsPartialUpdate( String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/field-mappings") - .addPathSegment(fieldMappingId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient + .fieldMappingsPartialUpdate(fieldMappingId, request, requestOptions) + .body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve() { - return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + return this.rawClient.remoteFieldsRetrieve().body(); } /** * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. */ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { - return remoteFieldsRetrieve(request, null); + return this.rawClient.remoteFieldsRetrieve(request).body(); } /** @@ -270,80 +130,20 @@ public RemoteFieldApiResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest r */ public RemoteFieldApiResponse remoteFieldsRetrieve( RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/remote-fields"); - if (request.getCommonModels().isPresent()) { - httpUrl.addQueryParameter("common_models", request.getCommonModels().get()); - } - if (request.getIncludeExampleValues().isPresent()) { - httpUrl.addQueryParameter( - "include_example_values", request.getIncludeExampleValues().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldsRetrieve(request, requestOptions).body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve() { - return targetFieldsRetrieve(null); + return this.rawClient.targetFieldsRetrieve().body(); } /** * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. */ public ExternalTargetFieldApiResponse targetFieldsRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/target-fields") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ExternalTargetFieldApiResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.targetFieldsRetrieve(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/fieldmapping/RawFieldMappingClient.java b/src/main/java/com/merge/api/resources/ticketing/fieldmapping/RawFieldMappingClient.java new file mode 100644 index 000000000..fc0cac7fe --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/fieldmapping/RawFieldMappingClient.java @@ -0,0 +1,380 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.fieldmapping; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.fieldmapping.requests.CreateFieldMappingRequest; +import com.merge.api.resources.ticketing.fieldmapping.requests.FieldMappingsRetrieveRequest; +import com.merge.api.resources.ticketing.fieldmapping.requests.PatchedEditFieldMappingRequest; +import com.merge.api.resources.ticketing.fieldmapping.requests.RemoteFieldsRetrieveRequest; +import com.merge.api.resources.ticketing.types.ExternalTargetFieldApiResponse; +import com.merge.api.resources.ticketing.types.FieldMappingApiInstanceResponse; +import com.merge.api.resources.ticketing.types.FieldMappingInstanceResponse; +import com.merge.api.resources.ticketing.types.RemoteFieldApiResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawFieldMappingClient { + protected final ClientOptions clientOptions; + + public RawFieldMappingClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve() { + return fieldMappingsRetrieve(FieldMappingsRetrieveRequest.builder().build()); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request) { + return fieldMappingsRetrieve(request, null); + } + + /** + * Get all Field Mappings for this Linked Account. Field Mappings are mappings between third-party Remote Fields and user defined Merge fields. Learn more. + */ + public MergeApiHttpResponse fieldMappingsRetrieve( + FieldMappingsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), FieldMappingApiInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate(CreateFieldMappingRequest request) { + return fieldMappingsCreate(request, null); + } + + /** + * Create new Field Mappings that will be available after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsCreate( + CreateFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/field-mappings"); + if (request.getExcludeRemoteFieldMetadata().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "exclude_remote_field_metadata", + request.getExcludeRemoteFieldMetadata().get().toString(), + false); + } + Map properties = new HashMap<>(); + properties.put("target_field_name", request.getTargetFieldName()); + properties.put("target_field_description", request.getTargetFieldDescription()); + properties.put("remote_field_traversal_path", request.getRemoteFieldTraversalPath()); + properties.put("remote_method", request.getRemoteMethod()); + properties.put("remote_url_path", request.getRemoteUrlPath()); + properties.put("common_model_name", request.getCommonModelName()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy(String fieldMappingId) { + return fieldMappingsDestroy(fieldMappingId, null); + } + + /** + * Deletes Field Mappings for a Linked Account. All data related to this Field Mapping will be deleted and these changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsDestroy( + String fieldMappingId, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("DELETE", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate(String fieldMappingId) { + return fieldMappingsPartialUpdate( + fieldMappingId, PatchedEditFieldMappingRequest.builder().build()); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request) { + return fieldMappingsPartialUpdate(fieldMappingId, request, null); + } + + /** + * Create or update existing Field Mappings for a Linked Account. Changes will be reflected after the next scheduled sync. This will cause the next sync for this Linked Account to sync ALL data from start. + */ + public MergeApiHttpResponse fieldMappingsPartialUpdate( + String fieldMappingId, PatchedEditFieldMappingRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/field-mappings") + .addPathSegment(fieldMappingId) + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), FieldMappingInstanceResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve() { + return remoteFieldsRetrieve(RemoteFieldsRetrieveRequest.builder().build()); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve(RemoteFieldsRetrieveRequest request) { + return remoteFieldsRetrieve(request, null); + } + + /** + * Get all remote fields for a Linked Account. Remote fields are third-party fields that are accessible after initial sync if remote_data is enabled. You can use remote fields to override existing Merge fields or map a new Merge field. Learn more. + */ + public MergeApiHttpResponse remoteFieldsRetrieve( + RemoteFieldsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/remote-fields"); + if (request.getCommonModels().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "common_models", request.getCommonModels().get(), false); + } + if (request.getIncludeExampleValues().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_example_values", + request.getIncludeExampleValues().get(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve() { + return targetFieldsRetrieve(null); + } + + /** + * Get all organization-wide Target Fields, this will not include any Linked Account specific Target Fields. Organization-wide Target Fields are additional fields appended to the Merge Common Model for all Linked Accounts in a category. Learn more. + */ + public MergeApiHttpResponse targetFieldsRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/target-fields") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), ExternalTargetFieldApiResponse.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/forceresync/AsyncForceResyncClient.java b/src/main/java/com/merge/api/resources/ticketing/forceresync/AsyncForceResyncClient.java new file mode 100644 index 000000000..0022ae353 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/forceresync/AsyncForceResyncClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.forceresync; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.SyncStatus; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncForceResyncClient { + protected final ClientOptions clientOptions; + + private final AsyncRawForceResyncClient rawClient; + + public AsyncForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawForceResyncClient withRawResponse() { + return this.rawClient; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate() { + return this.rawClient.syncStatusResyncCreate().thenApply(response -> response.body()); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture> syncStatusResyncCreate(RequestOptions requestOptions) { + return this.rawClient.syncStatusResyncCreate(requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/forceresync/AsyncRawForceResyncClient.java b/src/main/java/com/merge/api/resources/ticketing/forceresync/AsyncRawForceResyncClient.java new file mode 100644 index 000000000..086281db0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/forceresync/AsyncRawForceResyncClient.java @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawForceResyncClient { + protected final ClientOptions clientOptions; + + public AsyncRawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public CompletableFuture>> syncStatusResyncCreate( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/forceresync/ForceResyncClient.java b/src/main/java/com/merge/api/resources/ticketing/forceresync/ForceResyncClient.java index c2194e9eb..803c64dab 100644 --- a/src/main/java/com/merge/api/resources/ticketing/forceresync/ForceResyncClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/forceresync/ForceResyncClient.java @@ -3,69 +3,39 @@ */ package com.merge.api.resources.ticketing.forceresync; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.types.SyncStatus; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ForceResyncClient { protected final ClientOptions clientOptions; + private final RawForceResyncClient rawClient; + public ForceResyncClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawForceResyncClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawForceResyncClient withRawResponse() { + return this.rawClient; } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate() { - return syncStatusResyncCreate(null); + return this.rawClient.syncStatusResyncCreate().body(); } /** - * Force re-sync of all models. This is available for all organizations via the dashboard. Force re-sync is also available programmatically via API for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. */ public List syncStatusResyncCreate(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/sync-status/resync") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.syncStatusResyncCreate(requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/forceresync/RawForceResyncClient.java b/src/main/java/com/merge/api/resources/ticketing/forceresync/RawForceResyncClient.java new file mode 100644 index 000000000..b619ff806 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/forceresync/RawForceResyncClient.java @@ -0,0 +1,75 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.forceresync; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.SyncStatus; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawForceResyncClient { + protected final ClientOptions clientOptions; + + public RawForceResyncClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate() { + return syncStatusResyncCreate(null); + } + + /** + * Force re-sync of all models. This endpoint is available for monthly, quarterly, and highest sync frequency customers on the Professional or Enterprise plans. Doing so will consume a sync credit for the relevant linked account. Force re-syncs can also be triggered manually in the Merge Dashboard and is available for all customers. + */ + public MergeApiHttpResponse> syncStatusResyncCreate(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/sync-status/resync") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", RequestBody.create("", null)) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/generatekey/AsyncGenerateKeyClient.java b/src/main/java/com/merge/api/resources/ticketing/generatekey/AsyncGenerateKeyClient.java new file mode 100644 index 000000000..87268194c --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/generatekey/AsyncGenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.generatekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.ticketing.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncGenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawGenerateKeyClient rawClient; + + public AsyncGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawGenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Create a remote key. + */ + public CompletableFuture create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/generatekey/AsyncRawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/ticketing/generatekey/AsyncRawGenerateKeyClient.java new file mode 100644 index 000000000..606cd5476 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/generatekey/AsyncRawGenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.ticketing.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public CompletableFuture> create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public CompletableFuture> create( + GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/generatekey/GenerateKeyClient.java b/src/main/java/com/merge/api/resources/ticketing/generatekey/GenerateKeyClient.java index 3d9185645..25f74cf6f 100644 --- a/src/main/java/com/merge/api/resources/ticketing/generatekey/GenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/generatekey/GenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.ticketing.generatekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.generatekey.requests.GenerateRemoteKeyRequest; import com.merge.api.resources.ticketing.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class GenerateKeyClient { protected final ClientOptions clientOptions; + private final RawGenerateKeyClient rawClient; + public GenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawGenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawGenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Create a remote key. */ public RemoteKey create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/generate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/generatekey/RawGenerateKeyClient.java b/src/main/java/com/merge/api/resources/ticketing/generatekey/RawGenerateKeyClient.java new file mode 100644 index 000000000..b76b8fdf5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/generatekey/RawGenerateKeyClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.generatekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.generatekey.requests.GenerateRemoteKeyRequest; +import com.merge.api.resources.ticketing.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawGenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawGenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request) { + return create(request, null); + } + + /** + * Create a remote key. + */ + public MergeApiHttpResponse create(GenerateRemoteKeyRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/generate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/issues/AsyncIssuesClient.java b/src/main/java/com/merge/api/resources/ticketing/issues/AsyncIssuesClient.java new file mode 100644 index 000000000..2446e8b05 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/issues/AsyncIssuesClient.java @@ -0,0 +1,64 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.issues; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.issues.requests.IssuesListRequest; +import com.merge.api.resources.ticketing.types.Issue; +import com.merge.api.resources.ticketing.types.PaginatedIssueList; +import java.util.concurrent.CompletableFuture; + +public class AsyncIssuesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawIssuesClient rawClient; + + public AsyncIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawIssuesClient withRawResponse() { + return this.rawClient; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture list(IssuesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Get a specific issue. + */ + public CompletableFuture retrieve(String id, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/issues/AsyncRawIssuesClient.java b/src/main/java/com/merge/api/resources/ticketing/issues/AsyncRawIssuesClient.java new file mode 100644 index 000000000..07ad06b52 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/issues/AsyncRawIssuesClient.java @@ -0,0 +1,226 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.issues.requests.IssuesListRequest; +import com.merge.api.resources.ticketing.types.Issue; +import com.merge.api.resources.ticketing.types.PaginatedIssueList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawIssuesClient { + protected final ClientOptions clientOptions; + + public AsyncRawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public CompletableFuture> list( + IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public CompletableFuture> retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/issues/IssuesClient.java b/src/main/java/com/merge/api/resources/ticketing/issues/IssuesClient.java index 17931c31c..65fc0b07f 100644 --- a/src/main/java/com/merge/api/resources/ticketing/issues/IssuesClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/issues/IssuesClient.java @@ -3,169 +3,61 @@ */ package com.merge.api.resources.ticketing.issues; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.issues.requests.IssuesListRequest; import com.merge.api.resources.ticketing.types.Issue; import com.merge.api.resources.ticketing.types.PaginatedIssueList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class IssuesClient { protected final ClientOptions clientOptions; + private final RawIssuesClient rawClient; + public IssuesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawIssuesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawIssuesClient withRawResponse() { + return this.rawClient; } /** * Gets all issues for Organization. */ public PaginatedIssueList list() { - return list(IssuesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Gets all issues for Organization. */ public PaginatedIssueList list(IssuesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/issues"); - if (request.getAccountToken().isPresent()) { - httpUrl.addQueryParameter("account_token", request.getAccountToken().get()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndDate().isPresent()) { - httpUrl.addQueryParameter("end_date", request.getEndDate().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getFirstIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_after", - request.getFirstIncidentTimeAfter().get().toString()); - } - if (request.getFirstIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "first_incident_time_before", - request.getFirstIncidentTimeBefore().get().toString()); - } - if (request.getIncludeMuted().isPresent()) { - httpUrl.addQueryParameter("include_muted", request.getIncludeMuted().get()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getLastIncidentTimeAfter().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_after", - request.getLastIncidentTimeAfter().get().toString()); - } - if (request.getLastIncidentTimeBefore().isPresent()) { - httpUrl.addQueryParameter( - "last_incident_time_before", - request.getLastIncidentTimeBefore().get().toString()); - } - if (request.getLinkedAccountId().isPresent()) { - httpUrl.addQueryParameter( - "linked_account_id", request.getLinkedAccountId().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStartDate().isPresent()) { - httpUrl.addQueryParameter("start_date", request.getStartDate().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Get a specific issue. */ public Issue retrieve(String id) { - return retrieve(id, null); + return this.rawClient.retrieve(id).body(); } /** * Get a specific issue. */ public Issue retrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/issues") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/issues/RawIssuesClient.java b/src/main/java/com/merge/api/resources/ticketing/issues/RawIssuesClient.java new file mode 100644 index 000000000..d2ffb6c76 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/issues/RawIssuesClient.java @@ -0,0 +1,194 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.issues; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.issues.requests.IssuesListRequest; +import com.merge.api.resources.ticketing.types.Issue; +import com.merge.api.resources.ticketing.types.PaginatedIssueList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawIssuesClient { + protected final ClientOptions clientOptions; + + public RawIssuesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list() { + return list(IssuesListRequest.builder().build()); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request) { + return list(request, null); + } + + /** + * Gets all issues for Organization. + */ + public MergeApiHttpResponse list(IssuesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/issues"); + if (request.getAccountToken().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_token", request.getAccountToken().get(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_date", request.getEndDate().get(), false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getFirstIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_after", + request.getFirstIncidentTimeAfter().get().toString(), + false); + } + if (request.getFirstIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "first_incident_time_before", + request.getFirstIncidentTimeBefore().get().toString(), + false); + } + if (request.getIncludeMuted().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "include_muted", request.getIncludeMuted().get(), false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getLastIncidentTimeAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_after", + request.getLastIncidentTimeAfter().get().toString(), + false); + } + if (request.getLastIncidentTimeBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "last_incident_time_before", + request.getLastIncidentTimeBefore().get().toString(), + false); + } + if (request.getLinkedAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "linked_account_id", request.getLinkedAccountId().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStartDate().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "start_date", request.getStartDate().get(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedIssueList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, null); + } + + /** + * Get a specific issue. + */ + public MergeApiHttpResponse retrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/issues") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Issue.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/AsyncLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/AsyncLinkedAccountsClient.java new file mode 100644 index 000000000..1d6d7fb9a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/AsyncLinkedAccountsClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.linkedaccounts; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.ticketing.types.PaginatedAccountDetailsAndActionsList; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkedAccountsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkedAccountsClient rawClient; + + public AsyncLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkedAccountsClient withRawResponse() { + return this.rawClient; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list(LinkedAccountsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/AsyncRawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/AsyncRawLinkedAccountsClient.java new file mode 100644 index 000000000..1ea274d26 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/AsyncRawLinkedAccountsClient.java @@ -0,0 +1,162 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.ticketing.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public CompletableFuture> list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = + new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/LinkedAccountsClient.java b/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/LinkedAccountsClient.java index cd5e77193..d9d1715dd 100644 --- a/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/LinkedAccountsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/LinkedAccountsClient.java @@ -3,40 +3,40 @@ */ package com.merge.api.resources.ticketing.linkedaccounts; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.linkedaccounts.requests.LinkedAccountsListRequest; import com.merge.api.resources.ticketing.types.PaginatedAccountDetailsAndActionsList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkedAccountsClient { protected final ClientOptions clientOptions; + private final RawLinkedAccountsClient rawClient; + public LinkedAccountsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkedAccountsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkedAccountsClient withRawResponse() { + return this.rawClient; } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list() { - return list(LinkedAccountsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * List linked accounts for your organization. */ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** @@ -44,80 +44,6 @@ public PaginatedAccountDetailsAndActionsList list(LinkedAccountsListRequest requ */ public PaginatedAccountDetailsAndActionsList list( LinkedAccountsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/linked-accounts"); - if (request.getCategory().isPresent()) { - httpUrl.addQueryParameter("category", request.getCategory().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEndUserEmailAddress().isPresent()) { - httpUrl.addQueryParameter( - "end_user_email_address", request.getEndUserEmailAddress().get()); - } - if (request.getEndUserOrganizationName().isPresent()) { - httpUrl.addQueryParameter( - "end_user_organization_name", - request.getEndUserOrganizationName().get()); - } - if (request.getEndUserOriginId().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_id", request.getEndUserOriginId().get()); - } - if (request.getEndUserOriginIds().isPresent()) { - httpUrl.addQueryParameter( - "end_user_origin_ids", request.getEndUserOriginIds().get()); - } - if (request.getId().isPresent()) { - httpUrl.addQueryParameter("id", request.getId().get()); - } - if (request.getIds().isPresent()) { - httpUrl.addQueryParameter("ids", request.getIds().get()); - } - if (request.getIncludeDuplicates().isPresent()) { - httpUrl.addQueryParameter( - "include_duplicates", request.getIncludeDuplicates().get().toString()); - } - if (request.getIntegrationName().isPresent()) { - httpUrl.addQueryParameter( - "integration_name", request.getIntegrationName().get()); - } - if (request.getIsTestAccount().isPresent()) { - httpUrl.addQueryParameter( - "is_test_account", request.getIsTestAccount().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), PaginatedAccountDetailsAndActionsList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/RawLinkedAccountsClient.java b/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/RawLinkedAccountsClient.java new file mode 100644 index 000000000..9d800cc33 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/linkedaccounts/RawLinkedAccountsClient.java @@ -0,0 +1,143 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.linkedaccounts; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.linkedaccounts.requests.LinkedAccountsListRequest; +import com.merge.api.resources.ticketing.types.PaginatedAccountDetailsAndActionsList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkedAccountsClient { + protected final ClientOptions clientOptions; + + public RawLinkedAccountsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list() { + return list(LinkedAccountsListRequest.builder().build()); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list(LinkedAccountsListRequest request) { + return list(request, null); + } + + /** + * List linked accounts for your organization. + */ + public MergeApiHttpResponse list( + LinkedAccountsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/linked-accounts"); + if (request.getCategory().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "category", request.getCategory().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEndUserEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_email_address", + request.getEndUserEmailAddress().get(), + false); + } + if (request.getEndUserOrganizationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_organization_name", + request.getEndUserOrganizationName().get(), + false); + } + if (request.getEndUserOriginId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "end_user_origin_id", request.getEndUserOriginId().get(), false); + } + if (request.getEndUserOriginIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "end_user_origin_ids", + request.getEndUserOriginIds().get(), + false); + } + if (request.getId().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "id", request.getId().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDuplicates().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_duplicates", + request.getIncludeDuplicates().get().toString(), + false); + } + if (request.getIntegrationName().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "integration_name", request.getIntegrationName().get(), false); + } + if (request.getIsTestAccount().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_test_account", request.getIsTestAccount().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedAccountDetailsAndActionsList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/linktoken/AsyncLinkTokenClient.java b/src/main/java/com/merge/api/resources/ticketing/linktoken/AsyncLinkTokenClient.java new file mode 100644 index 000000000..a394f8ce7 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/linktoken/AsyncLinkTokenClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.linktoken; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.ticketing.types.LinkToken; +import java.util.concurrent.CompletableFuture; + +public class AsyncLinkTokenClient { + protected final ClientOptions clientOptions; + + private final AsyncRawLinkTokenClient rawClient; + + public AsyncLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawLinkTokenClient withRawResponse() { + return this.rawClient; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture create(EndUserDetailsRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/linktoken/AsyncRawLinkTokenClient.java b/src/main/java/com/merge/api/resources/ticketing/linktoken/AsyncRawLinkTokenClient.java new file mode 100644 index 000000000..3fbab85fa --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/linktoken/AsyncRawLinkTokenClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.ticketing.types.LinkToken; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawLinkTokenClient { + protected final ClientOptions clientOptions; + + public AsyncRawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public CompletableFuture> create( + EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/linktoken/LinkTokenClient.java b/src/main/java/com/merge/api/resources/ticketing/linktoken/LinkTokenClient.java index b8c8c7949..b40c17934 100644 --- a/src/main/java/com/merge/api/resources/ticketing/linktoken/LinkTokenClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/linktoken/LinkTokenClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.ticketing.linktoken; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.linktoken.requests.EndUserDetailsRequest; import com.merge.api.resources.ticketing.types.LinkToken; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class LinkTokenClient { protected final ClientOptions clientOptions; + private final RawLinkTokenClient rawClient; + public LinkTokenClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawLinkTokenClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawLinkTokenClient withRawResponse() { + return this.rawClient; } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a link token to be used when linking a new end user. */ public LinkToken create(EndUserDetailsRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/link-token") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/linktoken/RawLinkTokenClient.java b/src/main/java/com/merge/api/resources/ticketing/linktoken/RawLinkTokenClient.java new file mode 100644 index 000000000..8471c694d --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/linktoken/RawLinkTokenClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.linktoken; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.linktoken.requests.EndUserDetailsRequest; +import com.merge.api.resources.ticketing.types.LinkToken; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawLinkTokenClient { + protected final ClientOptions clientOptions; + + public RawLinkTokenClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request) { + return create(request, null); + } + + /** + * Creates a link token to be used when linking a new end user. + */ + public MergeApiHttpResponse create(EndUserDetailsRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/link-token") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LinkToken.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/passthrough/AsyncPassthroughClient.java b/src/main/java/com/merge/api/resources/ticketing/passthrough/AsyncPassthroughClient.java new file mode 100644 index 000000000..ac8408b3d --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/passthrough/AsyncPassthroughClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.passthrough; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.DataPassthroughRequest; +import com.merge.api.resources.ticketing.types.RemoteResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncPassthroughClient { + protected final ClientOptions clientOptions; + + private final AsyncRawPassthroughClient rawClient; + + public AsyncPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawPassthroughClient withRawResponse() { + return this.rawClient; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture create(DataPassthroughRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/passthrough/AsyncRawPassthroughClient.java b/src/main/java/com/merge/api/resources/ticketing/passthrough/AsyncRawPassthroughClient.java new file mode 100644 index 000000000..e8643b51e --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/passthrough/AsyncRawPassthroughClient.java @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.DataPassthroughRequest; +import com.merge.api.resources.ticketing.types.RemoteResponse; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawPassthroughClient { + protected final ClientOptions clientOptions; + + public AsyncRawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public CompletableFuture> create( + DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/passthrough/PassthroughClient.java b/src/main/java/com/merge/api/resources/ticketing/passthrough/PassthroughClient.java index a3eff87cc..826c35d5c 100644 --- a/src/main/java/com/merge/api/resources/ticketing/passthrough/PassthroughClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/passthrough/PassthroughClient.java @@ -3,75 +3,39 @@ */ package com.merge.api.resources.ticketing.passthrough; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.types.DataPassthroughRequest; import com.merge.api.resources.ticketing.types.RemoteResponse; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class PassthroughClient { protected final ClientOptions clientOptions; + private final RawPassthroughClient rawClient; + public PassthroughClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawPassthroughClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawPassthroughClient withRawResponse() { + return this.rawClient; } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Pull data from an endpoint not currently supported by Merge. */ public RemoteResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/passthrough") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/passthrough/RawPassthroughClient.java b/src/main/java/com/merge/api/resources/ticketing/passthrough/RawPassthroughClient.java new file mode 100644 index 000000000..859efe3e8 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/passthrough/RawPassthroughClient.java @@ -0,0 +1,81 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.passthrough; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.DataPassthroughRequest; +import com.merge.api.resources.ticketing.types.RemoteResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawPassthroughClient { + protected final ClientOptions clientOptions; + + public RawPassthroughClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request) { + return create(request, null); + } + + /** + * Pull data from an endpoint not currently supported by Merge. + */ + public MergeApiHttpResponse create(DataPassthroughRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/passthrough") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/projects/AsyncProjectsClient.java b/src/main/java/com/merge/api/resources/ticketing/projects/AsyncProjectsClient.java new file mode 100644 index 000000000..4b2eaf5b4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/projects/AsyncProjectsClient.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.projects; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.projects.requests.ProjectsListRequest; +import com.merge.api.resources.ticketing.projects.requests.ProjectsRetrieveRequest; +import com.merge.api.resources.ticketing.projects.requests.ProjectsUsersListRequest; +import com.merge.api.resources.ticketing.types.PaginatedProjectList; +import com.merge.api.resources.ticketing.types.PaginatedUserList; +import com.merge.api.resources.ticketing.types.Project; +import java.util.concurrent.CompletableFuture; + +public class AsyncProjectsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawProjectsClient rawClient; + + public AsyncProjectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawProjectsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawProjectsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Project objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Project objects. + */ + public CompletableFuture list(ProjectsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Project objects. + */ + public CompletableFuture list(ProjectsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Project object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Project object with the given id. + */ + public CompletableFuture retrieve(String id, ProjectsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Project object with the given id. + */ + public CompletableFuture retrieve( + String id, ProjectsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture usersList(String parentId) { + return this.rawClient.usersList(parentId).thenApply(response -> response.body()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture usersList(String parentId, ProjectsUsersListRequest request) { + return this.rawClient.usersList(parentId, request).thenApply(response -> response.body()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture usersList( + String parentId, ProjectsUsersListRequest request, RequestOptions requestOptions) { + return this.rawClient.usersList(parentId, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/projects/AsyncRawProjectsClient.java b/src/main/java/com/merge/api/resources/ticketing/projects/AsyncRawProjectsClient.java new file mode 100644 index 000000000..e40d7031a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/projects/AsyncRawProjectsClient.java @@ -0,0 +1,331 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.projects; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.projects.requests.ProjectsListRequest; +import com.merge.api.resources.ticketing.projects.requests.ProjectsRetrieveRequest; +import com.merge.api.resources.ticketing.projects.requests.ProjectsUsersListRequest; +import com.merge.api.resources.ticketing.types.PaginatedProjectList; +import com.merge.api.resources.ticketing.types.PaginatedUserList; +import com.merge.api.resources.ticketing.types.Project; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawProjectsClient { + protected final ClientOptions clientOptions; + + public AsyncRawProjectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Project objects. + */ + public CompletableFuture> list() { + return list(ProjectsListRequest.builder().build()); + } + + /** + * Returns a list of Project objects. + */ + public CompletableFuture> list(ProjectsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Project objects. + */ + public CompletableFuture> list( + ProjectsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/projects"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedProjectList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Project object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, ProjectsRetrieveRequest.builder().build()); + } + + /** + * Returns a Project object with the given id. + */ + public CompletableFuture> retrieve(String id, ProjectsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Project object with the given id. + */ + public CompletableFuture> retrieve( + String id, ProjectsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/projects") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> usersList(String parentId) { + return usersList(parentId, ProjectsUsersListRequest.builder().build()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> usersList( + String parentId, ProjectsUsersListRequest request) { + return usersList(parentId, request, null); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> usersList( + String parentId, ProjectsUsersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/projects") + .addPathSegment(parentId) + .addPathSegments("users"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/projects/ProjectsClient.java b/src/main/java/com/merge/api/resources/ticketing/projects/ProjectsClient.java index 5e0d757f1..bf1f74265 100644 --- a/src/main/java/com/merge/api/resources/ticketing/projects/ProjectsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/projects/ProjectsClient.java @@ -3,10 +3,7 @@ */ package com.merge.api.resources.ticketing.projects; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.projects.requests.ProjectsListRequest; import com.merge.api.resources.ticketing.projects.requests.ProjectsRetrieveRequest; @@ -14,170 +11,78 @@ import com.merge.api.resources.ticketing.types.PaginatedProjectList; import com.merge.api.resources.ticketing.types.PaginatedUserList; import com.merge.api.resources.ticketing.types.Project; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ProjectsClient { protected final ClientOptions clientOptions; + private final RawProjectsClient rawClient; + public ProjectsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawProjectsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawProjectsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Project objects. */ public PaginatedProjectList list() { - return list(ProjectsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Project objects. */ public PaginatedProjectList list(ProjectsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Project objects. */ public PaginatedProjectList list(ProjectsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/projects"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedProjectList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Project object with the given id. */ public Project retrieve(String id) { - return retrieve(id, ProjectsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Project object with the given id. */ public Project retrieve(String id, ProjectsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Project object with the given id. */ public Project retrieve(String id, ProjectsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/projects") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Returns a list of User objects. */ public PaginatedUserList usersList(String parentId) { - return usersList(parentId, ProjectsUsersListRequest.builder().build()); + return this.rawClient.usersList(parentId).body(); } /** * Returns a list of User objects. */ public PaginatedUserList usersList(String parentId, ProjectsUsersListRequest request) { - return usersList(parentId, request, null); + return this.rawClient.usersList(parentId, request).body(); } /** @@ -185,56 +90,6 @@ public PaginatedUserList usersList(String parentId, ProjectsUsersListRequest req */ public PaginatedUserList usersList( String parentId, ProjectsUsersListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/projects") - .addPathSegment(parentId) - .addPathSegments("users"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.usersList(parentId, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/projects/RawProjectsClient.java b/src/main/java/com/merge/api/resources/ticketing/projects/RawProjectsClient.java new file mode 100644 index 000000000..e2d605d7a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/projects/RawProjectsClient.java @@ -0,0 +1,285 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.projects; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.projects.requests.ProjectsListRequest; +import com.merge.api.resources.ticketing.projects.requests.ProjectsRetrieveRequest; +import com.merge.api.resources.ticketing.projects.requests.ProjectsUsersListRequest; +import com.merge.api.resources.ticketing.types.PaginatedProjectList; +import com.merge.api.resources.ticketing.types.PaginatedUserList; +import com.merge.api.resources.ticketing.types.Project; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawProjectsClient { + protected final ClientOptions clientOptions; + + public RawProjectsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Project objects. + */ + public MergeApiHttpResponse list() { + return list(ProjectsListRequest.builder().build()); + } + + /** + * Returns a list of Project objects. + */ + public MergeApiHttpResponse list(ProjectsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Project objects. + */ + public MergeApiHttpResponse list(ProjectsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/projects"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedProjectList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Project object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, ProjectsRetrieveRequest.builder().build()); + } + + /** + * Returns a Project object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, ProjectsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Project object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, ProjectsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/projects") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Project.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse usersList(String parentId) { + return usersList(parentId, ProjectsUsersListRequest.builder().build()); + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse usersList(String parentId, ProjectsUsersListRequest request) { + return usersList(parentId, request, null); + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse usersList( + String parentId, ProjectsUsersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/projects") + .addPathSegment(parentId) + .addPathSegments("users"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/projects/requests/ProjectsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/projects/requests/ProjectsRetrieveRequest.java index 7fb18c7dc..2cc6dc003 100644 --- a/src/main/java/com/merge/api/resources/ticketing/projects/requests/ProjectsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/projects/requests/ProjectsRetrieveRequest.java @@ -22,10 +22,16 @@ public final class ProjectsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private ProjectsRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private ProjectsRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(ProjectsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(ProjectsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public ProjectsRetrieveRequest build() { - return new ProjectsRetrieveRequest(includeRemoteData, additionalProperties); + return new ProjectsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/projects/requests/ProjectsUsersListRequest.java b/src/main/java/com/merge/api/resources/ticketing/projects/requests/ProjectsUsersListRequest.java index 5e9a433e7..3a60ebe46 100644 --- a/src/main/java/com/merge/api/resources/ticketing/projects/requests/ProjectsUsersListRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/projects/requests/ProjectsUsersListRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ticketing.projects.types.ProjectsUsersListRequestExpand; +import com.merge.api.resources.ticketing.projects.types.ProjectsUsersListRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,9 +23,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ProjectsUsersListRequest.Builder.class) public final class ProjectsUsersListRequest { - private final Optional cursor; + private final Optional> expand; - private final Optional expand; + private final Optional cursor; private final Optional includeDeletedData; @@ -36,15 +38,15 @@ public final class ProjectsUsersListRequest { private final Map additionalProperties; private ProjectsUsersListRequest( + Optional> expand, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, Optional pageSize, Map additionalProperties) { - this.cursor = cursor; this.expand = expand; + this.cursor = cursor; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -53,19 +55,19 @@ private ProjectsUsersListRequest( } /** - * @return The pagination cursor value. + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; + @JsonProperty("expand") + public Optional> getExpand() { + return expand; } /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + * @return The pagination cursor value. */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; } /** @@ -112,8 +114,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(ProjectsUsersListRequest other) { - return cursor.equals(other.cursor) - && expand.equals(other.expand) + return expand.equals(other.expand) + && cursor.equals(other.cursor) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -123,8 +125,8 @@ private boolean equalTo(ProjectsUsersListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.cursor, this.expand, + this.cursor, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -142,9 +144,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional cursor = Optional.empty(); + private Optional> expand = Optional.empty(); - private Optional expand = Optional.empty(); + private Optional cursor = Optional.empty(); private Optional includeDeletedData = Optional.empty(); @@ -160,8 +162,8 @@ public static final class Builder { private Builder() {} public Builder from(ProjectsUsersListRequest other) { - cursor(other.getCursor()); expand(other.getExpand()); + cursor(other.getCursor()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -169,25 +171,30 @@ public Builder from(ProjectsUsersListRequest other) { return this; } - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; return this; } - public Builder cursor(String cursor) { - this.cursor = Optional.ofNullable(cursor); + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; + public Builder expand(ProjectsUsersListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); return this; } - public Builder expand(ProjectsUsersListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); return this; } @@ -237,8 +244,8 @@ public Builder pageSize(Integer pageSize) { public ProjectsUsersListRequest build() { return new ProjectsUsersListRequest( - cursor, expand, + cursor, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ticketing/projects/types/ProjectsUsersListRequestExpand.java b/src/main/java/com/merge/api/resources/ticketing/projects/types/ProjectsUsersListRequestExpand.java deleted file mode 100644 index b55183a18..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/projects/types/ProjectsUsersListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.projects.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ProjectsUsersListRequestExpand { - ROLES("roles"), - - TEAMS("teams"), - - TEAMS_ROLES("teams,roles"); - - private final String value; - - ProjectsUsersListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/projects/types/ProjectsUsersListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ticketing/projects/types/ProjectsUsersListRequestExpandItem.java new file mode 100644 index 000000000..449c62bb0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/projects/types/ProjectsUsersListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.projects.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ProjectsUsersListRequestExpandItem { + ROLES("roles"), + + TEAMS("teams"); + + private final String value; + + ProjectsUsersListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/regeneratekey/AsyncRawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/ticketing/regeneratekey/AsyncRawRegenerateKeyClient.java new file mode 100644 index 000000000..4886f90aa --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/regeneratekey/AsyncRawRegenerateKeyClient.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.ticketing.types.RemoteKey; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public AsyncRawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture> create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/regeneratekey/AsyncRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/ticketing/regeneratekey/AsyncRegenerateKeyClient.java new file mode 100644 index 000000000..9bc075a9a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/regeneratekey/AsyncRegenerateKeyClient.java @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.regeneratekey; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.ticketing.types.RemoteKey; +import java.util.concurrent.CompletableFuture; + +public class AsyncRegenerateKeyClient { + protected final ClientOptions clientOptions; + + private final AsyncRawRegenerateKeyClient rawClient; + + public AsyncRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawRegenerateKeyClient withRawResponse() { + return this.rawClient; + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Exchange remote keys. + */ + public CompletableFuture create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/regeneratekey/RawRegenerateKeyClient.java b/src/main/java/com/merge/api/resources/ticketing/regeneratekey/RawRegenerateKeyClient.java new file mode 100644 index 000000000..5cd1f079f --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/regeneratekey/RawRegenerateKeyClient.java @@ -0,0 +1,82 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.regeneratekey; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.regeneratekey.requests.RemoteKeyForRegenerationRequest; +import com.merge.api.resources.ticketing.types.RemoteKey; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawRegenerateKeyClient { + protected final ClientOptions clientOptions; + + public RawRegenerateKeyClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create(RemoteKeyForRegenerationRequest request) { + return create(request, null); + } + + /** + * Exchange remote keys. + */ + public MergeApiHttpResponse create( + RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/regenerate-key") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/regeneratekey/RegenerateKeyClient.java b/src/main/java/com/merge/api/resources/ticketing/regeneratekey/RegenerateKeyClient.java index e8cf0c19c..30a202484 100644 --- a/src/main/java/com/merge/api/resources/ticketing/regeneratekey/RegenerateKeyClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/regeneratekey/RegenerateKeyClient.java @@ -3,76 +3,39 @@ */ package com.merge.api.resources.ticketing.regeneratekey; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.regeneratekey.requests.RemoteKeyForRegenerationRequest; import com.merge.api.resources.ticketing.types.RemoteKey; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class RegenerateKeyClient { protected final ClientOptions clientOptions; + private final RawRegenerateKeyClient rawClient; + public RegenerateKeyClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawRegenerateKeyClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawRegenerateKeyClient withRawResponse() { + return this.rawClient; } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Exchange remote keys. */ public RemoteKey create(RemoteKeyForRegenerationRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/regenerate-key") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteKey.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/roles/AsyncRawRolesClient.java b/src/main/java/com/merge/api/resources/ticketing/roles/AsyncRawRolesClient.java new file mode 100644 index 000000000..63442893c --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/roles/AsyncRawRolesClient.java @@ -0,0 +1,229 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.roles; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.roles.requests.RolesListRequest; +import com.merge.api.resources.ticketing.roles.requests.RolesRetrieveRequest; +import com.merge.api.resources.ticketing.types.PaginatedRoleList; +import com.merge.api.resources.ticketing.types.Role; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawRolesClient { + protected final ClientOptions clientOptions; + + public AsyncRawRolesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Role objects. + */ + public CompletableFuture> list() { + return list(RolesListRequest.builder().build()); + } + + /** + * Returns a list of Role objects. + */ + public CompletableFuture> list(RolesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Role objects. + */ + public CompletableFuture> list( + RolesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/roles"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRoleList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Role object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, RolesRetrieveRequest.builder().build()); + } + + /** + * Returns a Role object with the given id. + */ + public CompletableFuture> retrieve(String id, RolesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Role object with the given id. + */ + public CompletableFuture> retrieve( + String id, RolesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/roles") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Role.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/roles/AsyncRolesClient.java b/src/main/java/com/merge/api/resources/ticketing/roles/AsyncRolesClient.java new file mode 100644 index 000000000..dfc4214f7 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/roles/AsyncRolesClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.roles; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.roles.requests.RolesListRequest; +import com.merge.api.resources.ticketing.roles.requests.RolesRetrieveRequest; +import com.merge.api.resources.ticketing.types.PaginatedRoleList; +import com.merge.api.resources.ticketing.types.Role; +import java.util.concurrent.CompletableFuture; + +public class AsyncRolesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawRolesClient rawClient; + + public AsyncRolesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawRolesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawRolesClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Role objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Role objects. + */ + public CompletableFuture list(RolesListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Role objects. + */ + public CompletableFuture list(RolesListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Role object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Role object with the given id. + */ + public CompletableFuture retrieve(String id, RolesRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Role object with the given id. + */ + public CompletableFuture retrieve(String id, RolesRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/roles/RawRolesClient.java b/src/main/java/com/merge/api/resources/ticketing/roles/RawRolesClient.java new file mode 100644 index 000000000..1c0cadf6e --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/roles/RawRolesClient.java @@ -0,0 +1,196 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.roles; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.roles.requests.RolesListRequest; +import com.merge.api.resources.ticketing.roles.requests.RolesRetrieveRequest; +import com.merge.api.resources.ticketing.types.PaginatedRoleList; +import com.merge.api.resources.ticketing.types.Role; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawRolesClient { + protected final ClientOptions clientOptions; + + public RawRolesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Role objects. + */ + public MergeApiHttpResponse list() { + return list(RolesListRequest.builder().build()); + } + + /** + * Returns a list of Role objects. + */ + public MergeApiHttpResponse list(RolesListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Role objects. + */ + public MergeApiHttpResponse list(RolesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/roles"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRoleList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Role object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, RolesRetrieveRequest.builder().build()); + } + + /** + * Returns a Role object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, RolesRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Role object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, RolesRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/roles") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Role.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/roles/RolesClient.java b/src/main/java/com/merge/api/resources/ticketing/roles/RolesClient.java index 91b5bbeec..39aafd961 100644 --- a/src/main/java/com/merge/api/resources/ticketing/roles/RolesClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/roles/RolesClient.java @@ -3,164 +3,69 @@ */ package com.merge.api.resources.ticketing.roles; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.roles.requests.RolesListRequest; import com.merge.api.resources.ticketing.roles.requests.RolesRetrieveRequest; import com.merge.api.resources.ticketing.types.PaginatedRoleList; import com.merge.api.resources.ticketing.types.Role; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class RolesClient { protected final ClientOptions clientOptions; + private final RawRolesClient rawClient; + public RolesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawRolesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawRolesClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Role objects. */ public PaginatedRoleList list() { - return list(RolesListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Role objects. */ public PaginatedRoleList list(RolesListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Role objects. */ public PaginatedRoleList list(RolesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/roles"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRoleList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Role object with the given id. */ public Role retrieve(String id) { - return retrieve(id, RolesRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Role object with the given id. */ public Role retrieve(String id, RolesRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Role object with the given id. */ public Role retrieve(String id, RolesRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/roles") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Role.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/roles/requests/RolesRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/roles/requests/RolesRetrieveRequest.java index b1cd109aa..76622e7e9 100644 --- a/src/main/java/com/merge/api/resources/ticketing/roles/requests/RolesRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/roles/requests/RolesRetrieveRequest.java @@ -22,10 +22,16 @@ public final class RolesRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private RolesRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private RolesRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(RolesRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(RolesRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public RolesRetrieveRequest build() { - return new RolesRetrieveRequest(includeRemoteData, additionalProperties); + return new RolesRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/scopes/AsyncRawScopesClient.java b/src/main/java/com/merge/api/resources/ticketing/scopes/AsyncRawScopesClient.java new file mode 100644 index 000000000..303831e02 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/scopes/AsyncRawScopesClient.java @@ -0,0 +1,217 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.ticketing.types.CommonModelScopeApi; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawScopesClient { + protected final ClientOptions clientOptions; + + public AsyncRawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture> defaultScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture> linkedAccountScopesRetrieve( + RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture> linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/scopes/AsyncScopesClient.java b/src/main/java/com/merge/api/resources/ticketing/scopes/AsyncScopesClient.java new file mode 100644 index 000000000..66018d7bd --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/scopes/AsyncScopesClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.scopes; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.ticketing.types.CommonModelScopeApi; +import java.util.concurrent.CompletableFuture; + +public class AsyncScopesClient { + protected final ClientOptions clientOptions; + + private final AsyncRawScopesClient rawClient; + + public AsyncScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawScopesClient withRawResponse() { + return this.rawClient; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve() { + return this.rawClient.defaultScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public CompletableFuture defaultScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.defaultScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve() { + return this.rawClient.linkedAccountScopesRetrieve().thenApply(response -> response.body()); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public CompletableFuture linkedAccountScopesRetrieve(RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return this.rawClient.linkedAccountScopesCreate(request).thenApply(response -> response.body()); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public CompletableFuture linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/scopes/RawScopesClient.java b/src/main/java/com/merge/api/resources/ticketing/scopes/RawScopesClient.java new file mode 100644 index 000000000..fc7e17e1e --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/scopes/RawScopesClient.java @@ -0,0 +1,172 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.scopes; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; +import com.merge.api.resources.ticketing.types.CommonModelScopeApi; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawScopesClient { + protected final ClientOptions clientOptions; + + public RawScopesClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve() { + return defaultScopesRetrieve(null); + } + + /** + * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. + */ + public MergeApiHttpResponse defaultScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/default-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve() { + return linkedAccountScopesRetrieve(null); + } + + /** + * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. + */ + public MergeApiHttpResponse linkedAccountScopesRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/linked-account-scopes") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request) { + return linkedAccountScopesCreate(request, null); + } + + /** + * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more + */ + public MergeApiHttpResponse linkedAccountScopesCreate( + LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/linked-account-scopes") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/scopes/ScopesClient.java b/src/main/java/com/merge/api/resources/ticketing/scopes/ScopesClient.java index 48fed55ea..1f2e924f2 100644 --- a/src/main/java/com/merge/api/resources/ticketing/scopes/ScopesClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/scopes/ScopesClient.java @@ -3,118 +3,61 @@ */ package com.merge.api.resources.ticketing.scopes; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.scopes.requests.LinkedAccountCommonModelScopeDeserializerRequest; import com.merge.api.resources.ticketing.types.CommonModelScopeApi; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class ScopesClient { protected final ClientOptions clientOptions; + private final RawScopesClient rawClient; + public ScopesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawScopesClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawScopesClient withRawResponse() { + return this.rawClient; } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve() { - return defaultScopesRetrieve(null); + return this.rawClient.defaultScopesRetrieve().body(); } /** * Get the default permissions for Merge Common Models and fields across all Linked Accounts of a given category. Learn more. */ public CommonModelScopeApi defaultScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/default-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.defaultScopesRetrieve(requestOptions).body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve() { - return linkedAccountScopesRetrieve(null); + return this.rawClient.linkedAccountScopesRetrieve().body(); } /** * Get all available permissions for Merge Common Models and fields for a single Linked Account. Learn more. */ public CommonModelScopeApi linkedAccountScopesRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/linked-account-scopes") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesRetrieve(requestOptions).body(); } /** * Update permissions for any Common Model or field for a single Linked Account. Any Scopes not set in this POST request will inherit the default Scopes. Learn more */ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelScopeDeserializerRequest request) { - return linkedAccountScopesCreate(request, null); + return this.rawClient.linkedAccountScopesCreate(request).body(); } /** @@ -122,40 +65,6 @@ public CommonModelScopeApi linkedAccountScopesCreate(LinkedAccountCommonModelSco */ public CommonModelScopeApi linkedAccountScopesCreate( LinkedAccountCommonModelScopeDeserializerRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/linked-account-scopes") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CommonModelScopeApi.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.linkedAccountScopesCreate(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/syncstatus/AsyncRawSyncStatusClient.java b/src/main/java/com/merge/api/resources/ticketing/syncstatus/AsyncRawSyncStatusClient.java new file mode 100644 index 000000000..6d7df22e9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/syncstatus/AsyncRawSyncStatusClient.java @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.ticketing.types.PaginatedSyncStatusList; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawSyncStatusClient { + protected final ClientOptions clientOptions; + + public AsyncRawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture> list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedSyncStatusList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/syncstatus/AsyncSyncStatusClient.java b/src/main/java/com/merge/api/resources/ticketing/syncstatus/AsyncSyncStatusClient.java new file mode 100644 index 000000000..31004d204 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/syncstatus/AsyncSyncStatusClient.java @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.syncstatus; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.ticketing.types.PaginatedSyncStatusList; +import java.util.concurrent.CompletableFuture; + +public class AsyncSyncStatusClient { + protected final ClientOptions clientOptions; + + private final AsyncRawSyncStatusClient rawClient; + + public AsyncSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawSyncStatusClient withRawResponse() { + return this.rawClient; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list(SyncStatusListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public CompletableFuture list( + SyncStatusListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/syncstatus/RawSyncStatusClient.java b/src/main/java/com/merge/api/resources/ticketing/syncstatus/RawSyncStatusClient.java new file mode 100644 index 000000000..733c8ea40 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/syncstatus/RawSyncStatusClient.java @@ -0,0 +1,88 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.syncstatus; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.syncstatus.requests.SyncStatusListRequest; +import com.merge.api.resources.ticketing.types.PaginatedSyncStatusList; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawSyncStatusClient { + protected final ClientOptions clientOptions; + + public RawSyncStatusClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list() { + return list(SyncStatusListRequest.builder().build()); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list(SyncStatusListRequest request) { + return list(request, null); + } + + /** + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + */ + public MergeApiHttpResponse list( + SyncStatusListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/sync-status"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/syncstatus/SyncStatusClient.java b/src/main/java/com/merge/api/resources/ticketing/syncstatus/SyncStatusClient.java index bdfb8a655..1cc0b608c 100644 --- a/src/main/java/com/merge/api/resources/ticketing/syncstatus/SyncStatusClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/syncstatus/SyncStatusClient.java @@ -3,78 +3,46 @@ */ package com.merge.api.resources.ticketing.syncstatus; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.syncstatus.requests.SyncStatusListRequest; import com.merge.api.resources.ticketing.types.PaginatedSyncStatusList; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class SyncStatusClient { protected final ClientOptions clientOptions; + private final RawSyncStatusClient rawClient; + public SyncStatusClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawSyncStatusClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawSyncStatusClient withRawResponse() { + return this.rawClient; } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list() { - return list(SyncStatusListRequest.builder().build()); + return this.rawClient.list().body(); } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** - * Get syncing status. Possible values: DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. + * Get sync status for the current sync and the most recently finished sync. last_sync_start represents the most recent time any sync began. last_sync_finished represents the most recent time any sync completed. These timestamps may correspond to different sync instances which may result in a sync start time being later than a separate sync completed time. To ensure you are retrieving the latest available data reference the last_sync_finished timestamp where last_sync_result is DONE. Possible values for status and last_sync_result are DISABLED, DONE, FAILED, PARTIALLY_SYNCED, PAUSED, SYNCING. Learn more about sync status in our Help Center. */ public PaginatedSyncStatusList list(SyncStatusListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/sync-status"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedSyncStatusList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/tags/AsyncRawTagsClient.java b/src/main/java/com/merge/api/resources/ticketing/tags/AsyncRawTagsClient.java new file mode 100644 index 000000000..243632bfa --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/tags/AsyncRawTagsClient.java @@ -0,0 +1,229 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.tags; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.tags.requests.TagsListRequest; +import com.merge.api.resources.ticketing.tags.requests.TagsRetrieveRequest; +import com.merge.api.resources.ticketing.types.PaginatedTagList; +import com.merge.api.resources.ticketing.types.Tag; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTagsClient { + protected final ClientOptions clientOptions; + + public AsyncRawTagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture> list() { + return list(TagsListRequest.builder().build()); + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture> list(TagsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture> list( + TagsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tags"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTagList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Tag object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TagsRetrieveRequest.builder().build()); + } + + /** + * Returns a Tag object with the given id. + */ + public CompletableFuture> retrieve(String id, TagsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Tag object with the given id. + */ + public CompletableFuture> retrieve( + String id, TagsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tags") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/tags/AsyncTagsClient.java b/src/main/java/com/merge/api/resources/ticketing/tags/AsyncTagsClient.java new file mode 100644 index 000000000..6d2cf1243 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/tags/AsyncTagsClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.tags; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.tags.requests.TagsListRequest; +import com.merge.api.resources.ticketing.tags.requests.TagsRetrieveRequest; +import com.merge.api.resources.ticketing.types.PaginatedTagList; +import com.merge.api.resources.ticketing.types.Tag; +import java.util.concurrent.CompletableFuture; + +public class AsyncTagsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTagsClient rawClient; + + public AsyncTagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTagsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTagsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture list(TagsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Tag objects. + */ + public CompletableFuture list(TagsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Tag object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Tag object with the given id. + */ + public CompletableFuture retrieve(String id, TagsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Tag object with the given id. + */ + public CompletableFuture retrieve(String id, TagsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/tags/RawTagsClient.java b/src/main/java/com/merge/api/resources/ticketing/tags/RawTagsClient.java new file mode 100644 index 000000000..bb8563ece --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/tags/RawTagsClient.java @@ -0,0 +1,196 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.tags; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.tags.requests.TagsListRequest; +import com.merge.api.resources.ticketing.tags.requests.TagsRetrieveRequest; +import com.merge.api.resources.ticketing.types.PaginatedTagList; +import com.merge.api.resources.ticketing.types.Tag; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTagsClient { + protected final ClientOptions clientOptions; + + public RawTagsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Tag objects. + */ + public MergeApiHttpResponse list() { + return list(TagsListRequest.builder().build()); + } + + /** + * Returns a list of Tag objects. + */ + public MergeApiHttpResponse list(TagsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Tag objects. + */ + public MergeApiHttpResponse list(TagsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tags"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTagList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Tag object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TagsRetrieveRequest.builder().build()); + } + + /** + * Returns a Tag object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TagsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Tag object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TagsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tags") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/tags/TagsClient.java b/src/main/java/com/merge/api/resources/ticketing/tags/TagsClient.java index ef526798a..4bb651c7a 100644 --- a/src/main/java/com/merge/api/resources/ticketing/tags/TagsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/tags/TagsClient.java @@ -3,164 +3,69 @@ */ package com.merge.api.resources.ticketing.tags; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.tags.requests.TagsListRequest; import com.merge.api.resources.ticketing.tags.requests.TagsRetrieveRequest; import com.merge.api.resources.ticketing.types.PaginatedTagList; import com.merge.api.resources.ticketing.types.Tag; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TagsClient { protected final ClientOptions clientOptions; + private final RawTagsClient rawClient; + public TagsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTagsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTagsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Tag objects. */ public PaginatedTagList list() { - return list(TagsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Tag objects. */ public PaginatedTagList list(TagsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Tag objects. */ public PaginatedTagList list(TagsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/tags"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTagList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Tag object with the given id. */ public Tag retrieve(String id) { - return retrieve(id, TagsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Tag object with the given id. */ public Tag retrieve(String id, TagsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Tag object with the given id. */ public Tag retrieve(String id, TagsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/tags") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tag.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/tags/requests/TagsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/tags/requests/TagsRetrieveRequest.java index 8b74e7c55..c1aa4d6d7 100644 --- a/src/main/java/com/merge/api/resources/ticketing/tags/requests/TagsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/tags/requests/TagsRetrieveRequest.java @@ -22,10 +22,16 @@ public final class TagsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private TagsRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private TagsRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(TagsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(TagsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public TagsRetrieveRequest build() { - return new TagsRetrieveRequest(includeRemoteData, additionalProperties); + return new TagsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/teams/AsyncRawTeamsClient.java b/src/main/java/com/merge/api/resources/ticketing/teams/AsyncRawTeamsClient.java new file mode 100644 index 000000000..d3497c858 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/teams/AsyncRawTeamsClient.java @@ -0,0 +1,229 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.teams; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.teams.requests.TeamsListRequest; +import com.merge.api.resources.ticketing.teams.requests.TeamsRetrieveRequest; +import com.merge.api.resources.ticketing.types.PaginatedTeamList; +import com.merge.api.resources.ticketing.types.Team; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTeamsClient { + protected final ClientOptions clientOptions; + + public AsyncRawTeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture> list() { + return list(TeamsListRequest.builder().build()); + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture> list(TeamsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture> list( + TeamsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/teams"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTeamList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TeamsRetrieveRequest.builder().build()); + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture> retrieve(String id, TeamsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture> retrieve( + String id, TeamsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/teams") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/teams/AsyncTeamsClient.java b/src/main/java/com/merge/api/resources/ticketing/teams/AsyncTeamsClient.java new file mode 100644 index 000000000..6eec9102f --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/teams/AsyncTeamsClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.teams; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.teams.requests.TeamsListRequest; +import com.merge.api.resources.ticketing.teams.requests.TeamsRetrieveRequest; +import com.merge.api.resources.ticketing.types.PaginatedTeamList; +import com.merge.api.resources.ticketing.types.Team; +import java.util.concurrent.CompletableFuture; + +public class AsyncTeamsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTeamsClient rawClient; + + public AsyncTeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTeamsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTeamsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture list(TeamsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Team objects. + */ + public CompletableFuture list(TeamsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture retrieve(String id, TeamsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Team object with the given id. + */ + public CompletableFuture retrieve(String id, TeamsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/teams/RawTeamsClient.java b/src/main/java/com/merge/api/resources/ticketing/teams/RawTeamsClient.java new file mode 100644 index 000000000..e614b69a0 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/teams/RawTeamsClient.java @@ -0,0 +1,196 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.teams; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.teams.requests.TeamsListRequest; +import com.merge.api.resources.ticketing.teams.requests.TeamsRetrieveRequest; +import com.merge.api.resources.ticketing.types.PaginatedTeamList; +import com.merge.api.resources.ticketing.types.Team; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTeamsClient { + protected final ClientOptions clientOptions; + + public RawTeamsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Team objects. + */ + public MergeApiHttpResponse list() { + return list(TeamsListRequest.builder().build()); + } + + /** + * Returns a list of Team objects. + */ + public MergeApiHttpResponse list(TeamsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Team objects. + */ + public MergeApiHttpResponse list(TeamsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/teams"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTeamList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Team object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TeamsRetrieveRequest.builder().build()); + } + + /** + * Returns a Team object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TeamsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Team object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TeamsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/teams") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/teams/TeamsClient.java b/src/main/java/com/merge/api/resources/ticketing/teams/TeamsClient.java index 3f12e7825..9a5eb7ca8 100644 --- a/src/main/java/com/merge/api/resources/ticketing/teams/TeamsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/teams/TeamsClient.java @@ -3,164 +3,69 @@ */ package com.merge.api.resources.ticketing.teams; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.teams.requests.TeamsListRequest; import com.merge.api.resources.ticketing.teams.requests.TeamsRetrieveRequest; import com.merge.api.resources.ticketing.types.PaginatedTeamList; import com.merge.api.resources.ticketing.types.Team; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TeamsClient { protected final ClientOptions clientOptions; + private final RawTeamsClient rawClient; + public TeamsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTeamsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTeamsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Team objects. */ public PaginatedTeamList list() { - return list(TeamsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Team objects. */ public PaginatedTeamList list(TeamsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Team objects. */ public PaginatedTeamList list(TeamsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/teams"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTeamList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a Team object with the given id. */ public Team retrieve(String id) { - return retrieve(id, TeamsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Team object with the given id. */ public Team retrieve(String id, TeamsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Team object with the given id. */ public Team retrieve(String id, TeamsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/teams") - .addPathSegment(id); - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Team.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/teams/requests/TeamsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/teams/requests/TeamsRetrieveRequest.java index 466b6fb63..87778c41b 100644 --- a/src/main/java/com/merge/api/resources/ticketing/teams/requests/TeamsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/teams/requests/TeamsRetrieveRequest.java @@ -22,10 +22,16 @@ public final class TeamsRetrieveRequest { private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; - private TeamsRetrieveRequest(Optional includeRemoteData, Map additionalProperties) { + private TeamsRetrieveRequest( + Optional includeRemoteData, + Optional includeShellData, + Map additionalProperties) { this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -37,6 +43,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -49,12 +63,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(TeamsRetrieveRequest other) { - return includeRemoteData.equals(other.includeRemoteData); + return includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.includeRemoteData); + return Objects.hash(this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -70,6 +84,8 @@ public static Builder builder() { public static final class Builder { private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -77,6 +93,7 @@ private Builder() {} public Builder from(TeamsRetrieveRequest other) { includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @@ -91,8 +108,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public TeamsRetrieveRequest build() { - return new TeamsRetrieveRequest(includeRemoteData, additionalProperties); + return new TeamsRetrieveRequest(includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/AsyncRawTicketsClient.java b/src/main/java/com/merge/api/resources/ticketing/tickets/AsyncRawTicketsClient.java new file mode 100644 index 000000000..9c8dd16d5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/AsyncRawTicketsClient.java @@ -0,0 +1,847 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.tickets; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.tickets.requests.PatchedTicketEndpointRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketEndpointRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsListRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsRemoteFieldClassesListRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsRetrieveRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsViewersListRequest; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.ticketing.types.PaginatedTicketList; +import com.merge.api.resources.ticketing.types.PaginatedViewerList; +import com.merge.api.resources.ticketing.types.Ticket; +import com.merge.api.resources.ticketing.types.TicketResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawTicketsClient { + protected final ClientOptions clientOptions; + + public AsyncRawTicketsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Ticket objects. + */ + public CompletableFuture> list() { + return list(TicketsListRequest.builder().build()); + } + + /** + * Returns a list of Ticket objects. + */ + public CompletableFuture> list(TicketsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Ticket objects. + */ + public CompletableFuture> list( + TicketsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets"); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } + if (request.getAssigneeIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "assignee_ids", request.getAssigneeIds().get(), false); + } + if (request.getCollectionIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "collection_ids", request.getCollectionIds().get(), false); + } + if (request.getCompletedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "completed_after", + request.getCompletedAfter().get().toString(), + false); + } + if (request.getCompletedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "completed_before", + request.getCompletedBefore().get().toString(), + false); + } + if (request.getContactId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "contact_id", request.getContactId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getDueAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "due_after", request.getDueAfter().get().toString(), false); + } + if (request.getDueBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "due_before", request.getDueBefore().get().toString(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getParentTicketId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "parent_ticket_id", request.getParentTicketId().get(), false); + } + if (request.getPriority().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "priority", request.getPriority().get().toString(), false); + } + if (request.getRemoteCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_created_after", + request.getRemoteCreatedAfter().get().toString(), + false); + } + if (request.getRemoteCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_created_before", + request.getRemoteCreatedBefore().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getRemoteUpdatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_updated_after", + request.getRemoteUpdatedAfter().get().toString(), + false); + } + if (request.getRemoteUpdatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_updated_before", + request.getRemoteUpdatedBefore().get().toString(), + false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getTags().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tags", request.getTags().get(), false); + } + if (request.getTicketType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ticket_type", request.getTicketType().get(), false); + } + if (request.getTicketUrl().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ticket_url", request.getTicketUrl().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTicketList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a Ticket object with the given values. + */ + public CompletableFuture> create(TicketEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Ticket object with the given values. + */ + public CompletableFuture> create( + TicketEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a Ticket object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, TicketsRetrieveRequest.builder().build()); + } + + /** + * Returns a Ticket object with the given id. + */ + public CompletableFuture> retrieve(String id, TicketsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Ticket object with the given id. + */ + public CompletableFuture> retrieve( + String id, TicketsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Updates a Ticket object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedTicketEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates a Ticket object with the given id. + */ + public CompletableFuture> partialUpdate( + String id, PatchedTicketEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. + */ + public CompletableFuture> viewersList(String ticketId) { + return viewersList(ticketId, TicketsViewersListRequest.builder().build()); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. + */ + public CompletableFuture> viewersList( + String ticketId, TicketsViewersListRequest request) { + return viewersList(ticketId, request, null); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. + */ + public CompletableFuture> viewersList( + String ticketId, TicketsViewersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets") + .addPathSegment(ticketId) + .addPathSegments("viewers"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedViewerList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Ticket PATCHs. + */ + public CompletableFuture> metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Ticket PATCHs. + */ + public CompletableFuture> metaPatchRetrieve( + String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns metadata for Ticket POSTs. + */ + public CompletableFuture> metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Ticket POSTs. + */ + public CompletableFuture> metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList() { + return remoteFieldClassesList( + TicketsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + TicketsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture> remoteFieldClassesList( + TicketsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), PaginatedRemoteFieldClassList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/AsyncTicketsClient.java b/src/main/java/com/merge/api/resources/ticketing/tickets/AsyncTicketsClient.java new file mode 100644 index 000000000..9bc219174 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/AsyncTicketsClient.java @@ -0,0 +1,183 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.tickets; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.tickets.requests.PatchedTicketEndpointRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketEndpointRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsListRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsRemoteFieldClassesListRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsRetrieveRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsViewersListRequest; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.ticketing.types.PaginatedTicketList; +import com.merge.api.resources.ticketing.types.PaginatedViewerList; +import com.merge.api.resources.ticketing.types.Ticket; +import com.merge.api.resources.ticketing.types.TicketResponse; +import java.util.concurrent.CompletableFuture; + +public class AsyncTicketsClient { + protected final ClientOptions clientOptions; + + private final AsyncRawTicketsClient rawClient; + + public AsyncTicketsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawTicketsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawTicketsClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of Ticket objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of Ticket objects. + */ + public CompletableFuture list(TicketsListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Ticket objects. + */ + public CompletableFuture list(TicketsListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a Ticket object with the given values. + */ + public CompletableFuture create(TicketEndpointRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a Ticket object with the given values. + */ + public CompletableFuture create(TicketEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a Ticket object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a Ticket object with the given id. + */ + public CompletableFuture retrieve(String id, TicketsRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a Ticket object with the given id. + */ + public CompletableFuture retrieve( + String id, TicketsRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Updates a Ticket object with the given id. + */ + public CompletableFuture partialUpdate(String id, PatchedTicketEndpointRequest request) { + return this.rawClient.partialUpdate(id, request).thenApply(response -> response.body()); + } + + /** + * Updates a Ticket object with the given id. + */ + public CompletableFuture partialUpdate( + String id, PatchedTicketEndpointRequest request, RequestOptions requestOptions) { + return this.rawClient.partialUpdate(id, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. + */ + public CompletableFuture viewersList(String ticketId) { + return this.rawClient.viewersList(ticketId).thenApply(response -> response.body()); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. + */ + public CompletableFuture viewersList(String ticketId, TicketsViewersListRequest request) { + return this.rawClient.viewersList(ticketId, request).thenApply(response -> response.body()); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. + */ + public CompletableFuture viewersList( + String ticketId, TicketsViewersListRequest request, RequestOptions requestOptions) { + return this.rawClient.viewersList(ticketId, request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Ticket PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id) { + return this.rawClient.metaPatchRetrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Ticket PATCHs. + */ + public CompletableFuture metaPatchRetrieve(String id, RequestOptions requestOptions) { + return this.rawClient.metaPatchRetrieve(id, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns metadata for Ticket POSTs. + */ + public CompletableFuture metaPostRetrieve() { + return this.rawClient.metaPostRetrieve().thenApply(response -> response.body()); + } + + /** + * Returns metadata for Ticket POSTs. + */ + public CompletableFuture metaPostRetrieve(RequestOptions requestOptions) { + return this.rawClient.metaPostRetrieve(requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList() { + return this.rawClient.remoteFieldClassesList().thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + TicketsRemoteFieldClassesListRequest request) { + return this.rawClient.remoteFieldClassesList(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public CompletableFuture remoteFieldClassesList( + TicketsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + return this.rawClient.remoteFieldClassesList(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/RawTicketsClient.java b/src/main/java/com/merge/api/resources/ticketing/tickets/RawTicketsClient.java new file mode 100644 index 000000000..bfcc34f20 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/RawTicketsClient.java @@ -0,0 +1,729 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.tickets; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.tickets.requests.PatchedTicketEndpointRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketEndpointRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsListRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsRemoteFieldClassesListRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsRetrieveRequest; +import com.merge.api.resources.ticketing.tickets.requests.TicketsViewersListRequest; +import com.merge.api.resources.ticketing.types.MetaResponse; +import com.merge.api.resources.ticketing.types.PaginatedRemoteFieldClassList; +import com.merge.api.resources.ticketing.types.PaginatedTicketList; +import com.merge.api.resources.ticketing.types.PaginatedViewerList; +import com.merge.api.resources.ticketing.types.Ticket; +import com.merge.api.resources.ticketing.types.TicketResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawTicketsClient { + protected final ClientOptions clientOptions; + + public RawTicketsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of Ticket objects. + */ + public MergeApiHttpResponse list() { + return list(TicketsListRequest.builder().build()); + } + + /** + * Returns a list of Ticket objects. + */ + public MergeApiHttpResponse list(TicketsListRequest request) { + return list(request, null); + } + + /** + * Returns a list of Ticket objects. + */ + public MergeApiHttpResponse list(TicketsListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets"); + if (request.getAccountId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "account_id", request.getAccountId().get(), false); + } + if (request.getAssigneeIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "assignee_ids", request.getAssigneeIds().get(), false); + } + if (request.getCollectionIds().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "collection_ids", request.getCollectionIds().get(), false); + } + if (request.getCompletedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "completed_after", + request.getCompletedAfter().get().toString(), + false); + } + if (request.getCompletedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "completed_before", + request.getCompletedBefore().get().toString(), + false); + } + if (request.getContactId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "contact_id", request.getContactId().get(), false); + } + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getDueAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "due_after", request.getDueAfter().get().toString(), false); + } + if (request.getDueBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "due_before", request.getDueBefore().get().toString(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getParentTicketId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "parent_ticket_id", request.getParentTicketId().get(), false); + } + if (request.getPriority().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "priority", request.getPriority().get().toString(), false); + } + if (request.getRemoteCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_created_after", + request.getRemoteCreatedAfter().get().toString(), + false); + } + if (request.getRemoteCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_created_before", + request.getRemoteCreatedBefore().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getRemoteUpdatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_updated_after", + request.getRemoteUpdatedAfter().get().toString(), + false); + } + if (request.getRemoteUpdatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "remote_updated_before", + request.getRemoteUpdatedBefore().get().toString(), + false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getStatus().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "status", request.getStatus().get(), false); + } + if (request.getTags().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "tags", request.getTags().get(), false); + } + if (request.getTicketType().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ticket_type", request.getTicketType().get(), false); + } + if (request.getTicketUrl().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "ticket_url", request.getTicketUrl().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTicketList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a Ticket object with the given values. + */ + public MergeApiHttpResponse create(TicketEndpointRequest request) { + return create(request, null); + } + + /** + * Creates a Ticket object with the given values. + */ + public MergeApiHttpResponse create(TicketEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets"); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a Ticket object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, TicketsRetrieveRequest.builder().build()); + } + + /** + * Returns a Ticket object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, TicketsRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a Ticket object with the given id. + */ + public MergeApiHttpResponse retrieve( + String id, TicketsRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_fields", + request.getIncludeRemoteFields().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getRemoteFields().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_fields", request.getRemoteFields().get().toString(), false); + } + if (request.getShowEnumOrigins().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "show_enum_origins", + request.getShowEnumOrigins().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Updates a Ticket object with the given id. + */ + public MergeApiHttpResponse partialUpdate(String id, PatchedTicketEndpointRequest request) { + return partialUpdate(id, request, null); + } + + /** + * Updates a Ticket object with the given id. + */ + public MergeApiHttpResponse partialUpdate( + String id, PatchedTicketEndpointRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets") + .addPathSegment(id); + if (request.getIsDebugMode().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "is_debug_mode", request.getIsDebugMode().get().toString(), false); + } + if (request.getRunAsync().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "run_async", request.getRunAsync().get().toString(), false); + } + Map properties = new HashMap<>(); + properties.put("model", request.getModel()); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("PATCH", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. + */ + public MergeApiHttpResponse viewersList(String ticketId) { + return viewersList(ticketId, TicketsViewersListRequest.builder().build()); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. + */ + public MergeApiHttpResponse viewersList(String ticketId, TicketsViewersListRequest request) { + return viewersList(ticketId, request, null); + } + + /** + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. + */ + public MergeApiHttpResponse viewersList( + String ticketId, TicketsViewersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets") + .addPathSegment(ticketId) + .addPathSegments("viewers"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedViewerList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Ticket PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id) { + return metaPatchRetrieve(id, null); + } + + /** + * Returns metadata for Ticket PATCHs. + */ + public MergeApiHttpResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets/meta/patch") + .addPathSegment(id) + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns metadata for Ticket POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve() { + return metaPostRetrieve(null); + } + + /** + * Returns metadata for Ticket POSTs. + */ + public MergeApiHttpResponse metaPostRetrieve(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets/meta/post") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList() { + return remoteFieldClassesList( + TicketsRemoteFieldClassesListRequest.builder().build()); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + TicketsRemoteFieldClassesListRequest request) { + return remoteFieldClassesList(request, null); + } + + /** + * Returns a list of RemoteFieldClass objects. + */ + public MergeApiHttpResponse remoteFieldClassesList( + TicketsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/tickets/remote-field-classes"); + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getIds().isPresent()) { + QueryStringMapper.addQueryParameter(httpUrl, "ids", request.getIds().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getIsCommonModelField().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "is_common_model_field", + request.getIsCommonModelField().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/TicketsClient.java b/src/main/java/com/merge/api/resources/ticketing/tickets/TicketsClient.java index 1db4eccbc..736c656e9 100644 --- a/src/main/java/com/merge/api/resources/ticketing/tickets/TicketsClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/TicketsClient.java @@ -3,11 +3,7 @@ */ package com.merge.api.resources.ticketing.tickets; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.tickets.requests.PatchedTicketEndpointRequest; import com.merge.api.resources.ticketing.tickets.requests.TicketEndpointRequest; @@ -21,320 +17,85 @@ import com.merge.api.resources.ticketing.types.PaginatedViewerList; import com.merge.api.resources.ticketing.types.Ticket; import com.merge.api.resources.ticketing.types.TicketResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class TicketsClient { protected final ClientOptions clientOptions; + private final RawTicketsClient rawClient; + public TicketsClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawTicketsClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawTicketsClient withRawResponse() { + return this.rawClient; } /** * Returns a list of Ticket objects. */ public PaginatedTicketList list() { - return list(TicketsListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of Ticket objects. */ public PaginatedTicketList list(TicketsListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of Ticket objects. */ public PaginatedTicketList list(TicketsListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/tickets"); - if (request.getAccountId().isPresent()) { - httpUrl.addQueryParameter("account_id", request.getAccountId().get()); - } - if (request.getAssigneeIds().isPresent()) { - httpUrl.addQueryParameter("assignee_ids", request.getAssigneeIds().get()); - } - if (request.getCollectionIds().isPresent()) { - httpUrl.addQueryParameter( - "collection_ids", request.getCollectionIds().get()); - } - if (request.getCompletedAfter().isPresent()) { - httpUrl.addQueryParameter( - "completed_after", request.getCompletedAfter().get().toString()); - } - if (request.getCompletedBefore().isPresent()) { - httpUrl.addQueryParameter( - "completed_before", request.getCompletedBefore().get().toString()); - } - if (request.getContactId().isPresent()) { - httpUrl.addQueryParameter("contact_id", request.getContactId().get()); - } - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getDueAfter().isPresent()) { - httpUrl.addQueryParameter("due_after", request.getDueAfter().get().toString()); - } - if (request.getDueBefore().isPresent()) { - httpUrl.addQueryParameter("due_before", request.getDueBefore().get().toString()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getParentTicketId().isPresent()) { - httpUrl.addQueryParameter( - "parent_ticket_id", request.getParentTicketId().get()); - } - if (request.getPriority().isPresent()) { - httpUrl.addQueryParameter("priority", request.getPriority().get().toString()); - } - if (request.getRemoteCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "remote_created_after", - request.getRemoteCreatedAfter().get().toString()); - } - if (request.getRemoteCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "remote_created_before", - request.getRemoteCreatedBefore().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - if (request.getRemoteUpdatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "remote_updated_after", - request.getRemoteUpdatedAfter().get().toString()); - } - if (request.getRemoteUpdatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "remote_updated_before", - request.getRemoteUpdatedBefore().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get()); - } - if (request.getTags().isPresent()) { - httpUrl.addQueryParameter("tags", request.getTags().get()); - } - if (request.getTicketType().isPresent()) { - httpUrl.addQueryParameter("ticket_type", request.getTicketType().get()); - } - if (request.getTicketUrl().isPresent()) { - httpUrl.addQueryParameter("ticket_url", request.getTicketUrl().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedTicketList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Creates a Ticket object with the given values. */ public TicketResponse create(TicketEndpointRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a Ticket object with the given values. */ public TicketResponse create(TicketEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/tickets"); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } /** * Returns a Ticket object with the given id. */ public Ticket retrieve(String id) { - return retrieve(id, TicketsRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a Ticket object with the given id. */ public Ticket retrieve(String id, TicketsRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a Ticket object with the given id. */ public Ticket retrieve(String id, TicketsRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/tickets") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_fields", - request.getIncludeRemoteFields().get().toString()); - } - if (request.getRemoteFields().isPresent()) { - httpUrl.addQueryParameter( - "remote_fields", request.getRemoteFields().get().toString()); - } - if (request.getShowEnumOrigins().isPresent()) { - httpUrl.addQueryParameter( - "show_enum_origins", request.getShowEnumOrigins().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Ticket.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } /** * Updates a Ticket object with the given id. */ public TicketResponse partialUpdate(String id, PatchedTicketEndpointRequest request) { - return partialUpdate(id, request, null); + return this.rawClient.partialUpdate(id, request).body(); } /** @@ -342,220 +103,71 @@ public TicketResponse partialUpdate(String id, PatchedTicketEndpointRequest requ */ public TicketResponse partialUpdate( String id, PatchedTicketEndpointRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/tickets") - .addPathSegment(id); - if (request.getIsDebugMode().isPresent()) { - httpUrl.addQueryParameter( - "is_debug_mode", request.getIsDebugMode().get().toString()); - } - if (request.getRunAsync().isPresent()) { - httpUrl.addQueryParameter("run_async", request.getRunAsync().get().toString()); - } - Map properties = new HashMap<>(); - properties.put("model", request.getModel()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TicketResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.partialUpdate(id, request, requestOptions).body(); } /** - * Returns a list of Viewer objects. + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. */ public PaginatedViewerList viewersList(String ticketId) { - return viewersList(ticketId, TicketsViewersListRequest.builder().build()); + return this.rawClient.viewersList(ticketId).body(); } /** - * Returns a list of Viewer objects. + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. */ public PaginatedViewerList viewersList(String ticketId, TicketsViewersListRequest request) { - return viewersList(ticketId, request, null); + return this.rawClient.viewersList(ticketId, request).body(); } /** - * Returns a list of Viewer objects. + * Returns a list of Viewer objects that point to a User id or Team id that is either an assignee or viewer on a Ticket with the given id. Learn more. */ public PaginatedViewerList viewersList( String ticketId, TicketsViewersListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/tickets") - .addPathSegment(ticketId) - .addPathSegments("viewers"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedViewerList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.viewersList(ticketId, request, requestOptions).body(); } /** * Returns metadata for Ticket PATCHs. */ public MetaResponse metaPatchRetrieve(String id) { - return metaPatchRetrieve(id, null); + return this.rawClient.metaPatchRetrieve(id).body(); } /** * Returns metadata for Ticket PATCHs. */ public MetaResponse metaPatchRetrieve(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/tickets/meta/patch") - .addPathSegment(id) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPatchRetrieve(id, requestOptions).body(); } /** * Returns metadata for Ticket POSTs. */ public MetaResponse metaPostRetrieve() { - return metaPostRetrieve(null); + return this.rawClient.metaPostRetrieve().body(); } /** * Returns metadata for Ticket POSTs. */ public MetaResponse metaPostRetrieve(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/tickets/meta/post") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MetaResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.metaPostRetrieve(requestOptions).body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList() { - return remoteFieldClassesList( - TicketsRemoteFieldClassesListRequest.builder().build()); + return this.rawClient.remoteFieldClassesList().body(); } /** * Returns a list of RemoteFieldClass objects. */ public PaginatedRemoteFieldClassList remoteFieldClassesList(TicketsRemoteFieldClassesListRequest request) { - return remoteFieldClassesList(request, null); + return this.rawClient.remoteFieldClassesList(request).body(); } /** @@ -563,56 +175,6 @@ public PaginatedRemoteFieldClassList remoteFieldClassesList(TicketsRemoteFieldCl */ public PaginatedRemoteFieldClassList remoteFieldClassesList( TicketsRemoteFieldClassesListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/tickets/remote-field-classes"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getIsCommonModelField().isPresent()) { - httpUrl.addQueryParameter( - "is_common_model_field", - request.getIsCommonModelField().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedRemoteFieldClassList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.remoteFieldClassesList(request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsListRequest.java b/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsListRequest.java index 19d2d8a05..589473d3b 100644 --- a/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsListRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsListRequest.java @@ -12,12 +12,14 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ticketing.tickets.types.TicketsListRequestExpand; +import com.merge.api.resources.ticketing.tickets.types.TicketsListRequestExpandItem; import com.merge.api.resources.ticketing.tickets.types.TicketsListRequestPriority; import com.merge.api.resources.ticketing.tickets.types.TicketsListRequestRemoteFields; import com.merge.api.resources.ticketing.tickets.types.TicketsListRequestShowEnumOrigins; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -25,6 +27,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TicketsListRequest.Builder.class) public final class TicketsListRequest { + private final Optional> expand; + private final Optional accountId; private final Optional assigneeIds; @@ -47,8 +51,6 @@ public final class TicketsListRequest { private final Optional dueBefore; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -92,6 +94,7 @@ public final class TicketsListRequest { private final Map additionalProperties; private TicketsListRequest( + Optional> expand, Optional accountId, Optional assigneeIds, Optional collectionIds, @@ -103,7 +106,6 @@ private TicketsListRequest( Optional cursor, Optional dueAfter, Optional dueBefore, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeRemoteFields, @@ -125,6 +127,7 @@ private TicketsListRequest( Optional ticketType, Optional ticketUrl, Map additionalProperties) { + this.expand = expand; this.accountId = accountId; this.assigneeIds = assigneeIds; this.collectionIds = collectionIds; @@ -136,7 +139,6 @@ private TicketsListRequest( this.cursor = cursor; this.dueAfter = dueAfter; this.dueBefore = dueBefore; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; @@ -160,6 +162,14 @@ private TicketsListRequest( this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return tickets for this account. */ @@ -248,14 +258,6 @@ public Optional getDueBefore() { return dueBefore; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -434,7 +436,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(TicketsListRequest other) { - return accountId.equals(other.accountId) + return expand.equals(other.expand) + && accountId.equals(other.accountId) && assigneeIds.equals(other.assigneeIds) && collectionIds.equals(other.collectionIds) && completedAfter.equals(other.completedAfter) @@ -445,7 +448,6 @@ private boolean equalTo(TicketsListRequest other) { && cursor.equals(other.cursor) && dueAfter.equals(other.dueAfter) && dueBefore.equals(other.dueBefore) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) @@ -471,6 +473,7 @@ private boolean equalTo(TicketsListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.accountId, this.assigneeIds, this.collectionIds, @@ -482,7 +485,6 @@ public int hashCode() { this.cursor, this.dueAfter, this.dueBefore, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeRemoteFields, @@ -516,6 +518,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional accountId = Optional.empty(); private Optional assigneeIds = Optional.empty(); @@ -538,8 +542,6 @@ public static final class Builder { private Optional dueBefore = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -586,6 +588,7 @@ public static final class Builder { private Builder() {} public Builder from(TicketsListRequest other) { + expand(other.getExpand()); accountId(other.getAccountId()); assigneeIds(other.getAssigneeIds()); collectionIds(other.getCollectionIds()); @@ -597,7 +600,6 @@ public Builder from(TicketsListRequest other) { cursor(other.getCursor()); dueAfter(other.getDueAfter()); dueBefore(other.getDueBefore()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); @@ -621,6 +623,22 @@ public Builder from(TicketsListRequest other) { return this; } + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(TicketsListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "account_id", nulls = Nulls.SKIP) public Builder accountId(Optional accountId) { this.accountId = accountId; @@ -742,17 +760,6 @@ public Builder dueBefore(OffsetDateTime dueBefore) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(TicketsListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -975,6 +982,7 @@ public Builder ticketUrl(String ticketUrl) { public TicketsListRequest build() { return new TicketsListRequest( + expand, accountId, assigneeIds, collectionIds, @@ -986,7 +994,6 @@ public TicketsListRequest build() { cursor, dueAfter, dueBefore, - expand, includeDeletedData, includeRemoteData, includeRemoteFields, diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsRemoteFieldClassesListRequest.java b/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsRemoteFieldClassesListRequest.java index b9c1165fb..141d22071 100644 --- a/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsRemoteFieldClassesListRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsRemoteFieldClassesListRequest.java @@ -22,6 +22,8 @@ public final class TicketsRemoteFieldClassesListRequest { private final Optional cursor; + private final Optional ids; + private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -36,6 +38,7 @@ public final class TicketsRemoteFieldClassesListRequest { private TicketsRemoteFieldClassesListRequest( Optional cursor, + Optional ids, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -43,6 +46,7 @@ private TicketsRemoteFieldClassesListRequest( Optional pageSize, Map additionalProperties) { this.cursor = cursor; + this.ids = ids; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -59,6 +63,14 @@ public Optional getCursor() { return cursor; } + /** + * @return If provided, will only return remote field classes with the ids in this list + */ + @JsonProperty("ids") + public Optional getIds() { + return ids; + } + /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -113,6 +125,7 @@ public Map getAdditionalProperties() { private boolean equalTo(TicketsRemoteFieldClassesListRequest other) { return cursor.equals(other.cursor) + && ids.equals(other.ids) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -124,6 +137,7 @@ private boolean equalTo(TicketsRemoteFieldClassesListRequest other) { public int hashCode() { return Objects.hash( this.cursor, + this.ids, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -144,6 +158,8 @@ public static Builder builder() { public static final class Builder { private Optional cursor = Optional.empty(); + private Optional ids = Optional.empty(); + private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -161,6 +177,7 @@ private Builder() {} public Builder from(TicketsRemoteFieldClassesListRequest other) { cursor(other.getCursor()); + ids(other.getIds()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -180,6 +197,17 @@ public Builder cursor(String cursor) { return this; } + @JsonSetter(value = "ids", nulls = Nulls.SKIP) + public Builder ids(Optional ids) { + this.ids = ids; + return this; + } + + public Builder ids(String ids) { + this.ids = Optional.ofNullable(ids); + return this; + } + @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -238,6 +266,7 @@ public Builder pageSize(Integer pageSize) { public TicketsRemoteFieldClassesListRequest build() { return new TicketsRemoteFieldClassesListRequest( cursor, + ids, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsRetrieveRequest.java index d2f358ea3..e476e5ae5 100644 --- a/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsRetrieveRequest.java @@ -12,10 +12,12 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ticketing.tickets.types.TicketsRetrieveRequestExpand; +import com.merge.api.resources.ticketing.tickets.types.TicketsRetrieveRequestExpandItem; import com.merge.api.resources.ticketing.tickets.types.TicketsRetrieveRequestRemoteFields; import com.merge.api.resources.ticketing.tickets.types.TicketsRetrieveRequestShowEnumOrigins; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -23,12 +25,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TicketsRetrieveRequest.Builder.class) public final class TicketsRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; private final Optional includeRemoteFields; + private final Optional includeShellData; + private final Optional remoteFields; private final Optional showEnumOrigins; @@ -36,15 +40,17 @@ public final class TicketsRetrieveRequest { private final Map additionalProperties; private TicketsRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, Optional includeRemoteFields, + Optional includeShellData, Optional remoteFields, Optional showEnumOrigins, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; this.includeRemoteFields = includeRemoteFields; + this.includeShellData = includeShellData; this.remoteFields = remoteFields; this.showEnumOrigins = showEnumOrigins; this.additionalProperties = additionalProperties; @@ -54,7 +60,7 @@ private TicketsRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -74,6 +80,14 @@ public Optional getIncludeRemoteFields() { return includeRemoteFields; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + /** * @return Deprecated. Use show_enum_origins. */ @@ -105,6 +119,7 @@ private boolean equalTo(TicketsRetrieveRequest other) { return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData) && includeRemoteFields.equals(other.includeRemoteFields) + && includeShellData.equals(other.includeShellData) && remoteFields.equals(other.remoteFields) && showEnumOrigins.equals(other.showEnumOrigins); } @@ -112,7 +127,12 @@ private boolean equalTo(TicketsRetrieveRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.expand, this.includeRemoteData, this.includeRemoteFields, this.remoteFields, this.showEnumOrigins); + this.expand, + this.includeRemoteData, + this.includeRemoteFields, + this.includeShellData, + this.remoteFields, + this.showEnumOrigins); } @java.lang.Override @@ -126,12 +146,14 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); private Optional includeRemoteFields = Optional.empty(); + private Optional includeShellData = Optional.empty(); + private Optional remoteFields = Optional.empty(); private Optional showEnumOrigins = Optional.empty(); @@ -145,22 +167,28 @@ public Builder from(TicketsRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); includeRemoteFields(other.getIncludeRemoteFields()); + includeShellData(other.getIncludeShellData()); remoteFields(other.getRemoteFields()); showEnumOrigins(other.getShowEnumOrigins()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(TicketsRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(TicketsRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -183,6 +211,17 @@ public Builder includeRemoteFields(Boolean includeRemoteFields) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + @JsonSetter(value = "remote_fields", nulls = Nulls.SKIP) public Builder remoteFields(Optional remoteFields) { this.remoteFields = remoteFields; @@ -210,6 +249,7 @@ public TicketsRetrieveRequest build() { expand, includeRemoteData, includeRemoteFields, + includeShellData, remoteFields, showEnumOrigins, additionalProperties); diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsViewersListRequest.java b/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsViewersListRequest.java index 50e6f5c63..35d1e6675 100644 --- a/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsViewersListRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/requests/TicketsViewersListRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ticketing.tickets.types.TicketsViewersListRequestExpand; +import com.merge.api.resources.ticketing.tickets.types.TicketsViewersListRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,9 +23,9 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = TicketsViewersListRequest.Builder.class) public final class TicketsViewersListRequest { - private final Optional cursor; + private final Optional> expand; - private final Optional expand; + private final Optional cursor; private final Optional includeDeletedData; @@ -36,15 +38,15 @@ public final class TicketsViewersListRequest { private final Map additionalProperties; private TicketsViewersListRequest( + Optional> expand, Optional cursor, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, Optional pageSize, Map additionalProperties) { - this.cursor = cursor; this.expand = expand; + this.cursor = cursor; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -53,19 +55,19 @@ private TicketsViewersListRequest( } /** - * @return The pagination cursor value. + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; + @JsonProperty("expand") + public Optional> getExpand() { + return expand; } /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + * @return The pagination cursor value. */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; + @JsonProperty("cursor") + public Optional getCursor() { + return cursor; } /** @@ -112,8 +114,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(TicketsViewersListRequest other) { - return cursor.equals(other.cursor) - && expand.equals(other.expand) + return expand.equals(other.expand) + && cursor.equals(other.cursor) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) @@ -123,8 +125,8 @@ private boolean equalTo(TicketsViewersListRequest other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.cursor, this.expand, + this.cursor, this.includeDeletedData, this.includeRemoteData, this.includeShellData, @@ -142,9 +144,9 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional cursor = Optional.empty(); + private Optional> expand = Optional.empty(); - private Optional expand = Optional.empty(); + private Optional cursor = Optional.empty(); private Optional includeDeletedData = Optional.empty(); @@ -160,8 +162,8 @@ public static final class Builder { private Builder() {} public Builder from(TicketsViewersListRequest other) { - cursor(other.getCursor()); expand(other.getExpand()); + cursor(other.getCursor()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -169,25 +171,30 @@ public Builder from(TicketsViewersListRequest other) { return this; } - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; return this; } - public Builder cursor(String cursor) { - this.cursor = Optional.ofNullable(cursor); + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; + public Builder expand(TicketsViewersListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); return this; } - public Builder expand(TicketsViewersListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); + @JsonSetter(value = "cursor", nulls = Nulls.SKIP) + public Builder cursor(Optional cursor) { + this.cursor = cursor; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = Optional.ofNullable(cursor); return this; } @@ -237,8 +244,8 @@ public Builder pageSize(Integer pageSize) { public TicketsViewersListRequest build() { return new TicketsViewersListRequest( - cursor, expand, + cursor, includeDeletedData, includeRemoteData, includeShellData, diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsListRequestExpand.java b/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsListRequestExpand.java deleted file mode 100644 index 0418c1ab0..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsListRequestExpand.java +++ /dev/null @@ -1,586 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.tickets.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TicketsListRequestExpand { - ACCOUNT("account"), - - ACCOUNT_CONTACT("account,contact"), - - ACCOUNT_CONTACT_CREATOR("account,contact,creator"), - - ACCOUNT_CONTACT_CREATOR_PARENT_TICKET("account,contact,creator,parent_ticket"), - - ACCOUNT_CONTACT_PARENT_TICKET("account,contact,parent_ticket"), - - ACCOUNT_CREATOR("account,creator"), - - ACCOUNT_CREATOR_PARENT_TICKET("account,creator,parent_ticket"), - - ACCOUNT_PARENT_TICKET("account,parent_ticket"), - - ASSIGNED_TEAMS("assigned_teams"), - - ASSIGNED_TEAMS_ACCOUNT("assigned_teams,account"), - - ASSIGNED_TEAMS_ACCOUNT_CONTACT("assigned_teams,account,contact"), - - ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR("assigned_teams,account,contact,creator"), - - ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET("assigned_teams,account,contact,creator,parent_ticket"), - - ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET("assigned_teams,account,contact,parent_ticket"), - - ASSIGNED_TEAMS_ACCOUNT_CREATOR("assigned_teams,account,creator"), - - ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET("assigned_teams,account,creator,parent_ticket"), - - ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET("assigned_teams,account,parent_ticket"), - - ASSIGNED_TEAMS_CONTACT("assigned_teams,contact"), - - ASSIGNED_TEAMS_CONTACT_CREATOR("assigned_teams,contact,creator"), - - ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET("assigned_teams,contact,creator,parent_ticket"), - - ASSIGNED_TEAMS_CONTACT_PARENT_TICKET("assigned_teams,contact,parent_ticket"), - - ASSIGNED_TEAMS_CREATOR("assigned_teams,creator"), - - ASSIGNED_TEAMS_CREATOR_PARENT_TICKET("assigned_teams,creator,parent_ticket"), - - ASSIGNED_TEAMS_PARENT_TICKET("assigned_teams,parent_ticket"), - - ASSIGNEES("assignees"), - - ASSIGNEES_ACCOUNT("assignees,account"), - - ASSIGNEES_ACCOUNT_CONTACT("assignees,account,contact"), - - ASSIGNEES_ACCOUNT_CONTACT_CREATOR("assignees,account,contact,creator"), - - ASSIGNEES_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET("assignees,account,contact,creator,parent_ticket"), - - ASSIGNEES_ACCOUNT_CONTACT_PARENT_TICKET("assignees,account,contact,parent_ticket"), - - ASSIGNEES_ACCOUNT_CREATOR("assignees,account,creator"), - - ASSIGNEES_ACCOUNT_CREATOR_PARENT_TICKET("assignees,account,creator,parent_ticket"), - - ASSIGNEES_ACCOUNT_PARENT_TICKET("assignees,account,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS("assignees,assigned_teams"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT("assignees,assigned_teams,account"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT("assignees,assigned_teams,account,contact"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR("assignees,assigned_teams,account,contact,creator"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "assignees,assigned_teams,account,contact,creator,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET("assignees,assigned_teams,account,contact,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CREATOR("assignees,assigned_teams,account,creator"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET("assignees,assigned_teams,account,creator,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET("assignees,assigned_teams,account,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_CONTACT("assignees,assigned_teams,contact"), - - ASSIGNEES_ASSIGNED_TEAMS_CONTACT_CREATOR("assignees,assigned_teams,contact,creator"), - - ASSIGNEES_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET("assignees,assigned_teams,contact,creator,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET("assignees,assigned_teams,contact,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_CREATOR("assignees,assigned_teams,creator"), - - ASSIGNEES_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET("assignees,assigned_teams,creator,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_PARENT_TICKET("assignees,assigned_teams,parent_ticket"), - - ASSIGNEES_COLLECTIONS("assignees,collections"), - - ASSIGNEES_COLLECTIONS_ACCOUNT("assignees,collections,account"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT("assignees,collections,account,contact"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_CREATOR("assignees,collections,account,contact,creator"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "assignees,collections,account,contact,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_PARENT_TICKET("assignees,collections,account,contact,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CREATOR("assignees,collections,account,creator"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CREATOR_PARENT_TICKET("assignees,collections,account,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_PARENT_TICKET("assignees,collections,account,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS("assignees,collections,assigned_teams"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT("assignees,collections,assigned_teams,account"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT("assignees,collections,assigned_teams,account,contact"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR( - "assignees,collections,assigned_teams,account,contact,creator"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "assignees,collections,assigned_teams,account,contact,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "assignees,collections,assigned_teams,account,contact,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR("assignees,collections,assigned_teams,account,creator"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "assignees,collections,assigned_teams,account,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET( - "assignees,collections,assigned_teams,account,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT("assignees,collections,assigned_teams,contact"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR("assignees,collections,assigned_teams,contact,creator"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "assignees,collections,assigned_teams,contact,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET( - "assignees,collections,assigned_teams,contact,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CREATOR("assignees,collections,assigned_teams,creator"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET( - "assignees,collections,assigned_teams,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_PARENT_TICKET("assignees,collections,assigned_teams,parent_ticket"), - - ASSIGNEES_COLLECTIONS_CONTACT("assignees,collections,contact"), - - ASSIGNEES_COLLECTIONS_CONTACT_CREATOR("assignees,collections,contact,creator"), - - ASSIGNEES_COLLECTIONS_CONTACT_CREATOR_PARENT_TICKET("assignees,collections,contact,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_CONTACT_PARENT_TICKET("assignees,collections,contact,parent_ticket"), - - ASSIGNEES_COLLECTIONS_CREATOR("assignees,collections,creator"), - - ASSIGNEES_COLLECTIONS_CREATOR_PARENT_TICKET("assignees,collections,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_PARENT_TICKET("assignees,collections,parent_ticket"), - - ASSIGNEES_CONTACT("assignees,contact"), - - ASSIGNEES_CONTACT_CREATOR("assignees,contact,creator"), - - ASSIGNEES_CONTACT_CREATOR_PARENT_TICKET("assignees,contact,creator,parent_ticket"), - - ASSIGNEES_CONTACT_PARENT_TICKET("assignees,contact,parent_ticket"), - - ASSIGNEES_CREATOR("assignees,creator"), - - ASSIGNEES_CREATOR_PARENT_TICKET("assignees,creator,parent_ticket"), - - ASSIGNEES_PARENT_TICKET("assignees,parent_ticket"), - - ATTACHMENTS("attachments"), - - ATTACHMENTS_ACCOUNT("attachments,account"), - - ATTACHMENTS_ACCOUNT_CONTACT("attachments,account,contact"), - - ATTACHMENTS_ACCOUNT_CONTACT_CREATOR("attachments,account,contact,creator"), - - ATTACHMENTS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET("attachments,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ACCOUNT_CONTACT_PARENT_TICKET("attachments,account,contact,parent_ticket"), - - ATTACHMENTS_ACCOUNT_CREATOR("attachments,account,creator"), - - ATTACHMENTS_ACCOUNT_CREATOR_PARENT_TICKET("attachments,account,creator,parent_ticket"), - - ATTACHMENTS_ACCOUNT_PARENT_TICKET("attachments,account,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS("attachments,assigned_teams"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT("attachments,assigned_teams,account"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CONTACT("attachments,assigned_teams,account,contact"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR("attachments,assigned_teams,account,contact,creator"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assigned_teams,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "attachments,assigned_teams,account,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CREATOR("attachments,assigned_teams,account,creator"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "attachments,assigned_teams,account,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET("attachments,assigned_teams,account,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_CONTACT("attachments,assigned_teams,contact"), - - ATTACHMENTS_ASSIGNED_TEAMS_CONTACT_CREATOR("attachments,assigned_teams,contact,creator"), - - ATTACHMENTS_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assigned_teams,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET("attachments,assigned_teams,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_CREATOR("attachments,assigned_teams,creator"), - - ATTACHMENTS_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET("attachments,assigned_teams,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_PARENT_TICKET("attachments,assigned_teams,parent_ticket"), - - ATTACHMENTS_ASSIGNEES("attachments,assignees"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT("attachments,assignees,account"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CONTACT("attachments,assignees,account,contact"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CONTACT_CREATOR("attachments,assignees,account,contact,creator"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CONTACT_PARENT_TICKET("attachments,assignees,account,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CREATOR("attachments,assignees,account,creator"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CREATOR_PARENT_TICKET("attachments,assignees,account,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_PARENT_TICKET("attachments,assignees,account,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS("attachments,assignees,assigned_teams"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT("attachments,assignees,assigned_teams,account"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT("attachments,assignees,assigned_teams,account,contact"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR( - "attachments,assignees,assigned_teams,account,contact,creator"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,assigned_teams,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "attachments,assignees,assigned_teams,account,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CREATOR("attachments,assignees,assigned_teams,account,creator"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "attachments,assignees,assigned_teams,account,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET( - "attachments,assignees,assigned_teams,account,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CONTACT("attachments,assignees,assigned_teams,contact"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CONTACT_CREATOR("attachments,assignees,assigned_teams,contact,creator"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,assigned_teams,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET( - "attachments,assignees,assigned_teams,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CREATOR("attachments,assignees,assigned_teams,creator"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET( - "attachments,assignees,assigned_teams,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_PARENT_TICKET("attachments,assignees,assigned_teams,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS("attachments,assignees,collections"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT("attachments,assignees,collections,account"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT("attachments,assignees,collections,account,contact"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_CREATOR( - "attachments,assignees,collections,account,contact,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_PARENT_TICKET( - "attachments,assignees,collections,account,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CREATOR("attachments,assignees,collections,account,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,account,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_PARENT_TICKET("attachments,assignees,collections,account,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS("attachments,assignees,collections,assigned_teams"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT( - "attachments,assignees,collections,assigned_teams,account"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT( - "attachments,assignees,collections,assigned_teams,account,contact"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR( - "attachments,assignees,collections,assigned_teams,account,contact,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,account,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR( - "attachments,assignees,collections,assigned_teams,account,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,account,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,account,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT( - "attachments,assignees,collections,assigned_teams,contact"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR( - "attachments,assignees,collections,assigned_teams,contact,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CREATOR( - "attachments,assignees,collections,assigned_teams,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CONTACT("attachments,assignees,collections,contact"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CONTACT_CREATOR("attachments,assignees,collections,contact,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CONTACT_PARENT_TICKET("attachments,assignees,collections,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CREATOR("attachments,assignees,collections,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CREATOR_PARENT_TICKET("attachments,assignees,collections,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_PARENT_TICKET("attachments,assignees,collections,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_CONTACT("attachments,assignees,contact"), - - ATTACHMENTS_ASSIGNEES_CONTACT_CREATOR("attachments,assignees,contact,creator"), - - ATTACHMENTS_ASSIGNEES_CONTACT_CREATOR_PARENT_TICKET("attachments,assignees,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_CONTACT_PARENT_TICKET("attachments,assignees,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_CREATOR("attachments,assignees,creator"), - - ATTACHMENTS_ASSIGNEES_CREATOR_PARENT_TICKET("attachments,assignees,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_PARENT_TICKET("attachments,assignees,parent_ticket"), - - ATTACHMENTS_COLLECTIONS("attachments,collections"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT("attachments,collections,account"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CONTACT("attachments,collections,account,contact"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CONTACT_CREATOR("attachments,collections,account,contact,creator"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,collections,account,contact,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CONTACT_PARENT_TICKET("attachments,collections,account,contact,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CREATOR("attachments,collections,account,creator"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CREATOR_PARENT_TICKET("attachments,collections,account,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_PARENT_TICKET("attachments,collections,account,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS("attachments,collections,assigned_teams"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT("attachments,collections,assigned_teams,account"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT("attachments,collections,assigned_teams,account,contact"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR( - "attachments,collections,assigned_teams,account,contact,creator"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,collections,assigned_teams,account,contact,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "attachments,collections,assigned_teams,account,contact,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR("attachments,collections,assigned_teams,account,creator"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "attachments,collections,assigned_teams,account,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET( - "attachments,collections,assigned_teams,account,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CONTACT("attachments,collections,assigned_teams,contact"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR("attachments,collections,assigned_teams,contact,creator"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "attachments,collections,assigned_teams,contact,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET( - "attachments,collections,assigned_teams,contact,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CREATOR("attachments,collections,assigned_teams,creator"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET( - "attachments,collections,assigned_teams,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_PARENT_TICKET("attachments,collections,assigned_teams,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_CONTACT("attachments,collections,contact"), - - ATTACHMENTS_COLLECTIONS_CONTACT_CREATOR("attachments,collections,contact,creator"), - - ATTACHMENTS_COLLECTIONS_CONTACT_CREATOR_PARENT_TICKET("attachments,collections,contact,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_CONTACT_PARENT_TICKET("attachments,collections,contact,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_CREATOR("attachments,collections,creator"), - - ATTACHMENTS_COLLECTIONS_CREATOR_PARENT_TICKET("attachments,collections,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_PARENT_TICKET("attachments,collections,parent_ticket"), - - ATTACHMENTS_CONTACT("attachments,contact"), - - ATTACHMENTS_CONTACT_CREATOR("attachments,contact,creator"), - - ATTACHMENTS_CONTACT_CREATOR_PARENT_TICKET("attachments,contact,creator,parent_ticket"), - - ATTACHMENTS_CONTACT_PARENT_TICKET("attachments,contact,parent_ticket"), - - ATTACHMENTS_CREATOR("attachments,creator"), - - ATTACHMENTS_CREATOR_PARENT_TICKET("attachments,creator,parent_ticket"), - - ATTACHMENTS_PARENT_TICKET("attachments,parent_ticket"), - - COLLECTIONS("collections"), - - COLLECTIONS_ACCOUNT("collections,account"), - - COLLECTIONS_ACCOUNT_CONTACT("collections,account,contact"), - - COLLECTIONS_ACCOUNT_CONTACT_CREATOR("collections,account,contact,creator"), - - COLLECTIONS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET("collections,account,contact,creator,parent_ticket"), - - COLLECTIONS_ACCOUNT_CONTACT_PARENT_TICKET("collections,account,contact,parent_ticket"), - - COLLECTIONS_ACCOUNT_CREATOR("collections,account,creator"), - - COLLECTIONS_ACCOUNT_CREATOR_PARENT_TICKET("collections,account,creator,parent_ticket"), - - COLLECTIONS_ACCOUNT_PARENT_TICKET("collections,account,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS("collections,assigned_teams"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT("collections,assigned_teams,account"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT("collections,assigned_teams,account,contact"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR("collections,assigned_teams,account,contact,creator"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "collections,assigned_teams,account,contact,creator,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "collections,assigned_teams,account,contact,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR("collections,assigned_teams,account,creator"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "collections,assigned_teams,account,creator,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET("collections,assigned_teams,account,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_CONTACT("collections,assigned_teams,contact"), - - COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR("collections,assigned_teams,contact,creator"), - - COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "collections,assigned_teams,contact,creator,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET("collections,assigned_teams,contact,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_CREATOR("collections,assigned_teams,creator"), - - COLLECTIONS_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET("collections,assigned_teams,creator,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_PARENT_TICKET("collections,assigned_teams,parent_ticket"), - - COLLECTIONS_CONTACT("collections,contact"), - - COLLECTIONS_CONTACT_CREATOR("collections,contact,creator"), - - COLLECTIONS_CONTACT_CREATOR_PARENT_TICKET("collections,contact,creator,parent_ticket"), - - COLLECTIONS_CONTACT_PARENT_TICKET("collections,contact,parent_ticket"), - - COLLECTIONS_CREATOR("collections,creator"), - - COLLECTIONS_CREATOR_PARENT_TICKET("collections,creator,parent_ticket"), - - COLLECTIONS_PARENT_TICKET("collections,parent_ticket"), - - CONTACT("contact"), - - CONTACT_CREATOR("contact,creator"), - - CONTACT_CREATOR_PARENT_TICKET("contact,creator,parent_ticket"), - - CONTACT_PARENT_TICKET("contact,parent_ticket"), - - CREATOR("creator"), - - CREATOR_PARENT_TICKET("creator,parent_ticket"), - - PARENT_TICKET("parent_ticket"); - - private final String value; - - TicketsListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsListRequestExpandItem.java new file mode 100644 index 000000000..541e7c61a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsListRequestExpandItem.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.tickets.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TicketsListRequestExpandItem { + ACCOUNT("account"), + + ASSIGNED_TEAMS("assigned_teams"), + + ASSIGNEES("assignees"), + + ATTACHMENTS("attachments"), + + COLLECTIONS("collections"), + + CONTACT("contact"), + + CREATOR("creator"), + + PARENT_TICKET("parent_ticket"); + + private final String value; + + TicketsListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsRetrieveRequestExpand.java deleted file mode 100644 index db93e13a7..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsRetrieveRequestExpand.java +++ /dev/null @@ -1,586 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.tickets.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TicketsRetrieveRequestExpand { - ACCOUNT("account"), - - ACCOUNT_CONTACT("account,contact"), - - ACCOUNT_CONTACT_CREATOR("account,contact,creator"), - - ACCOUNT_CONTACT_CREATOR_PARENT_TICKET("account,contact,creator,parent_ticket"), - - ACCOUNT_CONTACT_PARENT_TICKET("account,contact,parent_ticket"), - - ACCOUNT_CREATOR("account,creator"), - - ACCOUNT_CREATOR_PARENT_TICKET("account,creator,parent_ticket"), - - ACCOUNT_PARENT_TICKET("account,parent_ticket"), - - ASSIGNED_TEAMS("assigned_teams"), - - ASSIGNED_TEAMS_ACCOUNT("assigned_teams,account"), - - ASSIGNED_TEAMS_ACCOUNT_CONTACT("assigned_teams,account,contact"), - - ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR("assigned_teams,account,contact,creator"), - - ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET("assigned_teams,account,contact,creator,parent_ticket"), - - ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET("assigned_teams,account,contact,parent_ticket"), - - ASSIGNED_TEAMS_ACCOUNT_CREATOR("assigned_teams,account,creator"), - - ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET("assigned_teams,account,creator,parent_ticket"), - - ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET("assigned_teams,account,parent_ticket"), - - ASSIGNED_TEAMS_CONTACT("assigned_teams,contact"), - - ASSIGNED_TEAMS_CONTACT_CREATOR("assigned_teams,contact,creator"), - - ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET("assigned_teams,contact,creator,parent_ticket"), - - ASSIGNED_TEAMS_CONTACT_PARENT_TICKET("assigned_teams,contact,parent_ticket"), - - ASSIGNED_TEAMS_CREATOR("assigned_teams,creator"), - - ASSIGNED_TEAMS_CREATOR_PARENT_TICKET("assigned_teams,creator,parent_ticket"), - - ASSIGNED_TEAMS_PARENT_TICKET("assigned_teams,parent_ticket"), - - ASSIGNEES("assignees"), - - ASSIGNEES_ACCOUNT("assignees,account"), - - ASSIGNEES_ACCOUNT_CONTACT("assignees,account,contact"), - - ASSIGNEES_ACCOUNT_CONTACT_CREATOR("assignees,account,contact,creator"), - - ASSIGNEES_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET("assignees,account,contact,creator,parent_ticket"), - - ASSIGNEES_ACCOUNT_CONTACT_PARENT_TICKET("assignees,account,contact,parent_ticket"), - - ASSIGNEES_ACCOUNT_CREATOR("assignees,account,creator"), - - ASSIGNEES_ACCOUNT_CREATOR_PARENT_TICKET("assignees,account,creator,parent_ticket"), - - ASSIGNEES_ACCOUNT_PARENT_TICKET("assignees,account,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS("assignees,assigned_teams"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT("assignees,assigned_teams,account"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT("assignees,assigned_teams,account,contact"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR("assignees,assigned_teams,account,contact,creator"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "assignees,assigned_teams,account,contact,creator,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET("assignees,assigned_teams,account,contact,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CREATOR("assignees,assigned_teams,account,creator"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET("assignees,assigned_teams,account,creator,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET("assignees,assigned_teams,account,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_CONTACT("assignees,assigned_teams,contact"), - - ASSIGNEES_ASSIGNED_TEAMS_CONTACT_CREATOR("assignees,assigned_teams,contact,creator"), - - ASSIGNEES_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET("assignees,assigned_teams,contact,creator,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET("assignees,assigned_teams,contact,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_CREATOR("assignees,assigned_teams,creator"), - - ASSIGNEES_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET("assignees,assigned_teams,creator,parent_ticket"), - - ASSIGNEES_ASSIGNED_TEAMS_PARENT_TICKET("assignees,assigned_teams,parent_ticket"), - - ASSIGNEES_COLLECTIONS("assignees,collections"), - - ASSIGNEES_COLLECTIONS_ACCOUNT("assignees,collections,account"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT("assignees,collections,account,contact"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_CREATOR("assignees,collections,account,contact,creator"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "assignees,collections,account,contact,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_PARENT_TICKET("assignees,collections,account,contact,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CREATOR("assignees,collections,account,creator"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_CREATOR_PARENT_TICKET("assignees,collections,account,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ACCOUNT_PARENT_TICKET("assignees,collections,account,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS("assignees,collections,assigned_teams"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT("assignees,collections,assigned_teams,account"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT("assignees,collections,assigned_teams,account,contact"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR( - "assignees,collections,assigned_teams,account,contact,creator"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "assignees,collections,assigned_teams,account,contact,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "assignees,collections,assigned_teams,account,contact,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR("assignees,collections,assigned_teams,account,creator"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "assignees,collections,assigned_teams,account,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET( - "assignees,collections,assigned_teams,account,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT("assignees,collections,assigned_teams,contact"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR("assignees,collections,assigned_teams,contact,creator"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "assignees,collections,assigned_teams,contact,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET( - "assignees,collections,assigned_teams,contact,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CREATOR("assignees,collections,assigned_teams,creator"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET( - "assignees,collections,assigned_teams,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_PARENT_TICKET("assignees,collections,assigned_teams,parent_ticket"), - - ASSIGNEES_COLLECTIONS_CONTACT("assignees,collections,contact"), - - ASSIGNEES_COLLECTIONS_CONTACT_CREATOR("assignees,collections,contact,creator"), - - ASSIGNEES_COLLECTIONS_CONTACT_CREATOR_PARENT_TICKET("assignees,collections,contact,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_CONTACT_PARENT_TICKET("assignees,collections,contact,parent_ticket"), - - ASSIGNEES_COLLECTIONS_CREATOR("assignees,collections,creator"), - - ASSIGNEES_COLLECTIONS_CREATOR_PARENT_TICKET("assignees,collections,creator,parent_ticket"), - - ASSIGNEES_COLLECTIONS_PARENT_TICKET("assignees,collections,parent_ticket"), - - ASSIGNEES_CONTACT("assignees,contact"), - - ASSIGNEES_CONTACT_CREATOR("assignees,contact,creator"), - - ASSIGNEES_CONTACT_CREATOR_PARENT_TICKET("assignees,contact,creator,parent_ticket"), - - ASSIGNEES_CONTACT_PARENT_TICKET("assignees,contact,parent_ticket"), - - ASSIGNEES_CREATOR("assignees,creator"), - - ASSIGNEES_CREATOR_PARENT_TICKET("assignees,creator,parent_ticket"), - - ASSIGNEES_PARENT_TICKET("assignees,parent_ticket"), - - ATTACHMENTS("attachments"), - - ATTACHMENTS_ACCOUNT("attachments,account"), - - ATTACHMENTS_ACCOUNT_CONTACT("attachments,account,contact"), - - ATTACHMENTS_ACCOUNT_CONTACT_CREATOR("attachments,account,contact,creator"), - - ATTACHMENTS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET("attachments,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ACCOUNT_CONTACT_PARENT_TICKET("attachments,account,contact,parent_ticket"), - - ATTACHMENTS_ACCOUNT_CREATOR("attachments,account,creator"), - - ATTACHMENTS_ACCOUNT_CREATOR_PARENT_TICKET("attachments,account,creator,parent_ticket"), - - ATTACHMENTS_ACCOUNT_PARENT_TICKET("attachments,account,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS("attachments,assigned_teams"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT("attachments,assigned_teams,account"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CONTACT("attachments,assigned_teams,account,contact"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR("attachments,assigned_teams,account,contact,creator"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assigned_teams,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "attachments,assigned_teams,account,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CREATOR("attachments,assigned_teams,account,creator"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "attachments,assigned_teams,account,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET("attachments,assigned_teams,account,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_CONTACT("attachments,assigned_teams,contact"), - - ATTACHMENTS_ASSIGNED_TEAMS_CONTACT_CREATOR("attachments,assigned_teams,contact,creator"), - - ATTACHMENTS_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assigned_teams,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET("attachments,assigned_teams,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_CREATOR("attachments,assigned_teams,creator"), - - ATTACHMENTS_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET("attachments,assigned_teams,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNED_TEAMS_PARENT_TICKET("attachments,assigned_teams,parent_ticket"), - - ATTACHMENTS_ASSIGNEES("attachments,assignees"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT("attachments,assignees,account"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CONTACT("attachments,assignees,account,contact"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CONTACT_CREATOR("attachments,assignees,account,contact,creator"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CONTACT_PARENT_TICKET("attachments,assignees,account,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CREATOR("attachments,assignees,account,creator"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_CREATOR_PARENT_TICKET("attachments,assignees,account,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ACCOUNT_PARENT_TICKET("attachments,assignees,account,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS("attachments,assignees,assigned_teams"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT("attachments,assignees,assigned_teams,account"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT("attachments,assignees,assigned_teams,account,contact"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR( - "attachments,assignees,assigned_teams,account,contact,creator"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,assigned_teams,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "attachments,assignees,assigned_teams,account,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CREATOR("attachments,assignees,assigned_teams,account,creator"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "attachments,assignees,assigned_teams,account,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET( - "attachments,assignees,assigned_teams,account,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CONTACT("attachments,assignees,assigned_teams,contact"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CONTACT_CREATOR("attachments,assignees,assigned_teams,contact,creator"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,assigned_teams,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET( - "attachments,assignees,assigned_teams,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CREATOR("attachments,assignees,assigned_teams,creator"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET( - "attachments,assignees,assigned_teams,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_ASSIGNED_TEAMS_PARENT_TICKET("attachments,assignees,assigned_teams,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS("attachments,assignees,collections"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT("attachments,assignees,collections,account"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT("attachments,assignees,collections,account,contact"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_CREATOR( - "attachments,assignees,collections,account,contact,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CONTACT_PARENT_TICKET( - "attachments,assignees,collections,account,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CREATOR("attachments,assignees,collections,account,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,account,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ACCOUNT_PARENT_TICKET("attachments,assignees,collections,account,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS("attachments,assignees,collections,assigned_teams"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT( - "attachments,assignees,collections,assigned_teams,account"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT( - "attachments,assignees,collections,assigned_teams,account,contact"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR( - "attachments,assignees,collections,assigned_teams,account,contact,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,account,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,account,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR( - "attachments,assignees,collections,assigned_teams,account,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,account,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,account,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT( - "attachments,assignees,collections,assigned_teams,contact"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR( - "attachments,assignees,collections,assigned_teams,contact,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CREATOR( - "attachments,assignees,collections,assigned_teams,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_ASSIGNED_TEAMS_PARENT_TICKET( - "attachments,assignees,collections,assigned_teams,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CONTACT("attachments,assignees,collections,contact"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CONTACT_CREATOR("attachments,assignees,collections,contact,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CONTACT_CREATOR_PARENT_TICKET( - "attachments,assignees,collections,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CONTACT_PARENT_TICKET("attachments,assignees,collections,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CREATOR("attachments,assignees,collections,creator"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_CREATOR_PARENT_TICKET("attachments,assignees,collections,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_COLLECTIONS_PARENT_TICKET("attachments,assignees,collections,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_CONTACT("attachments,assignees,contact"), - - ATTACHMENTS_ASSIGNEES_CONTACT_CREATOR("attachments,assignees,contact,creator"), - - ATTACHMENTS_ASSIGNEES_CONTACT_CREATOR_PARENT_TICKET("attachments,assignees,contact,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_CONTACT_PARENT_TICKET("attachments,assignees,contact,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_CREATOR("attachments,assignees,creator"), - - ATTACHMENTS_ASSIGNEES_CREATOR_PARENT_TICKET("attachments,assignees,creator,parent_ticket"), - - ATTACHMENTS_ASSIGNEES_PARENT_TICKET("attachments,assignees,parent_ticket"), - - ATTACHMENTS_COLLECTIONS("attachments,collections"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT("attachments,collections,account"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CONTACT("attachments,collections,account,contact"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CONTACT_CREATOR("attachments,collections,account,contact,creator"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,collections,account,contact,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CONTACT_PARENT_TICKET("attachments,collections,account,contact,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CREATOR("attachments,collections,account,creator"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_CREATOR_PARENT_TICKET("attachments,collections,account,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ACCOUNT_PARENT_TICKET("attachments,collections,account,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS("attachments,collections,assigned_teams"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT("attachments,collections,assigned_teams,account"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT("attachments,collections,assigned_teams,account,contact"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR( - "attachments,collections,assigned_teams,account,contact,creator"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "attachments,collections,assigned_teams,account,contact,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "attachments,collections,assigned_teams,account,contact,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR("attachments,collections,assigned_teams,account,creator"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "attachments,collections,assigned_teams,account,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET( - "attachments,collections,assigned_teams,account,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CONTACT("attachments,collections,assigned_teams,contact"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR("attachments,collections,assigned_teams,contact,creator"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "attachments,collections,assigned_teams,contact,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET( - "attachments,collections,assigned_teams,contact,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CREATOR("attachments,collections,assigned_teams,creator"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET( - "attachments,collections,assigned_teams,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_ASSIGNED_TEAMS_PARENT_TICKET("attachments,collections,assigned_teams,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_CONTACT("attachments,collections,contact"), - - ATTACHMENTS_COLLECTIONS_CONTACT_CREATOR("attachments,collections,contact,creator"), - - ATTACHMENTS_COLLECTIONS_CONTACT_CREATOR_PARENT_TICKET("attachments,collections,contact,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_CONTACT_PARENT_TICKET("attachments,collections,contact,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_CREATOR("attachments,collections,creator"), - - ATTACHMENTS_COLLECTIONS_CREATOR_PARENT_TICKET("attachments,collections,creator,parent_ticket"), - - ATTACHMENTS_COLLECTIONS_PARENT_TICKET("attachments,collections,parent_ticket"), - - ATTACHMENTS_CONTACT("attachments,contact"), - - ATTACHMENTS_CONTACT_CREATOR("attachments,contact,creator"), - - ATTACHMENTS_CONTACT_CREATOR_PARENT_TICKET("attachments,contact,creator,parent_ticket"), - - ATTACHMENTS_CONTACT_PARENT_TICKET("attachments,contact,parent_ticket"), - - ATTACHMENTS_CREATOR("attachments,creator"), - - ATTACHMENTS_CREATOR_PARENT_TICKET("attachments,creator,parent_ticket"), - - ATTACHMENTS_PARENT_TICKET("attachments,parent_ticket"), - - COLLECTIONS("collections"), - - COLLECTIONS_ACCOUNT("collections,account"), - - COLLECTIONS_ACCOUNT_CONTACT("collections,account,contact"), - - COLLECTIONS_ACCOUNT_CONTACT_CREATOR("collections,account,contact,creator"), - - COLLECTIONS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET("collections,account,contact,creator,parent_ticket"), - - COLLECTIONS_ACCOUNT_CONTACT_PARENT_TICKET("collections,account,contact,parent_ticket"), - - COLLECTIONS_ACCOUNT_CREATOR("collections,account,creator"), - - COLLECTIONS_ACCOUNT_CREATOR_PARENT_TICKET("collections,account,creator,parent_ticket"), - - COLLECTIONS_ACCOUNT_PARENT_TICKET("collections,account,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS("collections,assigned_teams"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT("collections,assigned_teams,account"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT("collections,assigned_teams,account,contact"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR("collections,assigned_teams,account,contact,creator"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_CREATOR_PARENT_TICKET( - "collections,assigned_teams,account,contact,creator,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CONTACT_PARENT_TICKET( - "collections,assigned_teams,account,contact,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR("collections,assigned_teams,account,creator"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_CREATOR_PARENT_TICKET( - "collections,assigned_teams,account,creator,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_ACCOUNT_PARENT_TICKET("collections,assigned_teams,account,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_CONTACT("collections,assigned_teams,contact"), - - COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR("collections,assigned_teams,contact,creator"), - - COLLECTIONS_ASSIGNED_TEAMS_CONTACT_CREATOR_PARENT_TICKET( - "collections,assigned_teams,contact,creator,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_CONTACT_PARENT_TICKET("collections,assigned_teams,contact,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_CREATOR("collections,assigned_teams,creator"), - - COLLECTIONS_ASSIGNED_TEAMS_CREATOR_PARENT_TICKET("collections,assigned_teams,creator,parent_ticket"), - - COLLECTIONS_ASSIGNED_TEAMS_PARENT_TICKET("collections,assigned_teams,parent_ticket"), - - COLLECTIONS_CONTACT("collections,contact"), - - COLLECTIONS_CONTACT_CREATOR("collections,contact,creator"), - - COLLECTIONS_CONTACT_CREATOR_PARENT_TICKET("collections,contact,creator,parent_ticket"), - - COLLECTIONS_CONTACT_PARENT_TICKET("collections,contact,parent_ticket"), - - COLLECTIONS_CREATOR("collections,creator"), - - COLLECTIONS_CREATOR_PARENT_TICKET("collections,creator,parent_ticket"), - - COLLECTIONS_PARENT_TICKET("collections,parent_ticket"), - - CONTACT("contact"), - - CONTACT_CREATOR("contact,creator"), - - CONTACT_CREATOR_PARENT_TICKET("contact,creator,parent_ticket"), - - CONTACT_PARENT_TICKET("contact,parent_ticket"), - - CREATOR("creator"), - - CREATOR_PARENT_TICKET("creator,parent_ticket"), - - PARENT_TICKET("parent_ticket"); - - private final String value; - - TicketsRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsRetrieveRequestExpandItem.java new file mode 100644 index 000000000..fbf51ea4c --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsRetrieveRequestExpandItem.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.tickets.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TicketsRetrieveRequestExpandItem { + ACCOUNT("account"), + + ASSIGNED_TEAMS("assigned_teams"), + + ASSIGNEES("assignees"), + + ATTACHMENTS("attachments"), + + COLLECTIONS("collections"), + + CONTACT("contact"), + + CREATOR("creator"), + + PARENT_TICKET("parent_ticket"); + + private final String value; + + TicketsRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsViewersListRequestExpand.java b/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsViewersListRequestExpand.java deleted file mode 100644 index 60c2fe992..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsViewersListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.tickets.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TicketsViewersListRequestExpand { - TEAM("team"), - - USER("user"), - - USER_TEAM("user,team"); - - private final String value; - - TicketsViewersListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsViewersListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsViewersListRequestExpandItem.java new file mode 100644 index 000000000..a84a91d0b --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/tickets/types/TicketsViewersListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.tickets.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TicketsViewersListRequestExpandItem { + TEAM("team"), + + USER("user"); + + private final String value; + + TicketsViewersListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/AccountToken.java b/src/main/java/com/merge/api/resources/ticketing/types/AccountToken.java index 4e107947e..3c18295db 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/AccountToken.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/AccountToken.java @@ -23,12 +23,15 @@ public final class AccountToken { private final AccountIntegration integration; + private final String id; + private final Map additionalProperties; private AccountToken( - String accountToken, AccountIntegration integration, Map additionalProperties) { + String accountToken, AccountIntegration integration, String id, Map additionalProperties) { this.accountToken = accountToken; this.integration = integration; + this.id = id; this.additionalProperties = additionalProperties; } @@ -42,6 +45,11 @@ public AccountIntegration getIntegration() { return integration; } + @JsonProperty("id") + public String getId() { + return id; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -54,12 +62,12 @@ public Map getAdditionalProperties() { } private boolean equalTo(AccountToken other) { - return accountToken.equals(other.accountToken) && integration.equals(other.integration); + return accountToken.equals(other.accountToken) && integration.equals(other.integration) && id.equals(other.id); } @java.lang.Override public int hashCode() { - return Objects.hash(this.accountToken, this.integration); + return Objects.hash(this.accountToken, this.integration, this.id); } @java.lang.Override @@ -78,7 +86,11 @@ public interface AccountTokenStage { } public interface IntegrationStage { - _FinalStage integration(@NotNull AccountIntegration integration); + IdStage integration(@NotNull AccountIntegration integration); + } + + public interface IdStage { + _FinalStage id(@NotNull String id); } public interface _FinalStage { @@ -86,11 +98,13 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AccountTokenStage, IntegrationStage, _FinalStage { + public static final class Builder implements AccountTokenStage, IntegrationStage, IdStage, _FinalStage { private String accountToken; private AccountIntegration integration; + private String id; + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -100,6 +114,7 @@ private Builder() {} public Builder from(AccountToken other) { accountToken(other.getAccountToken()); integration(other.getIntegration()); + id(other.getId()); return this; } @@ -112,14 +127,21 @@ public IntegrationStage accountToken(@NotNull String accountToken) { @java.lang.Override @JsonSetter("integration") - public _FinalStage integration(@NotNull AccountIntegration integration) { + public IdStage integration(@NotNull AccountIntegration integration) { this.integration = integration; return this; } + @java.lang.Override + @JsonSetter("id") + public _FinalStage id(@NotNull String id) { + this.id = id; + return this; + } + @java.lang.Override public AccountToken build() { - return new AccountToken(accountToken, integration, additionalProperties); + return new AccountToken(accountToken, integration, id, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/types/AttachmentRequestTicket.java b/src/main/java/com/merge/api/resources/ticketing/types/AttachmentRequestTicket.java index f520ac638..6f0eafeac 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/AttachmentRequestTicket.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/AttachmentRequestTicket.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public AttachmentRequestTicket deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public AttachmentRequestTicket deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/AttachmentTicket.java b/src/main/java/com/merge/api/resources/ticketing/types/AttachmentTicket.java index 7ff0b726e..35515e472 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/AttachmentTicket.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/AttachmentTicket.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public AttachmentTicket deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public AttachmentTicket deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/AuditLogEvent.java b/src/main/java/com/merge/api/resources/ticketing/types/AuditLogEvent.java index fd30c4cbe..c1cc7a6c8 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/AuditLogEvent.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/AuditLogEvent.java @@ -28,11 +28,11 @@ public final class AuditLogEvent { private final Optional userEmail; - private final AuditLogEventRole role; + private final RoleEnum role; private final String ipAddress; - private final AuditLogEventEventType eventType; + private final EventTypeEnum eventType; private final String eventDescription; @@ -44,9 +44,9 @@ private AuditLogEvent( Optional id, Optional userName, Optional userEmail, - AuditLogEventRole role, + RoleEnum role, String ipAddress, - AuditLogEventEventType eventType, + EventTypeEnum eventType, String eventDescription, Optional createdAt, Map additionalProperties) { @@ -94,7 +94,7 @@ public Optional getUserEmail() { * */ @JsonProperty("role") - public AuditLogEventRole getRole() { + public RoleEnum getRole() { return role; } @@ -115,6 +115,7 @@ public String getIpAddress() { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -150,7 +151,7 @@ public String getIpAddress() { * */ @JsonProperty("event_type") - public AuditLogEventEventType getEventType() { + public EventTypeEnum getEventType() { return eventType; } @@ -209,7 +210,7 @@ public static RoleStage builder() { } public interface RoleStage { - IpAddressStage role(@NotNull AuditLogEventRole role); + IpAddressStage role(@NotNull RoleEnum role); Builder from(AuditLogEvent other); } @@ -219,7 +220,7 @@ public interface IpAddressStage { } public interface EventTypeStage { - EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType); + EventDescriptionStage eventType(@NotNull EventTypeEnum eventType); } public interface EventDescriptionStage { @@ -249,11 +250,11 @@ public interface _FinalStage { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements RoleStage, IpAddressStage, EventTypeStage, EventDescriptionStage, _FinalStage { - private AuditLogEventRole role; + private RoleEnum role; private String ipAddress; - private AuditLogEventEventType eventType; + private EventTypeEnum eventType; private String eventDescription; @@ -297,7 +298,7 @@ public Builder from(AuditLogEvent other) { */ @java.lang.Override @JsonSetter("role") - public IpAddressStage role(@NotNull AuditLogEventRole role) { + public IpAddressStage role(@NotNull RoleEnum role) { this.role = role; return this; } @@ -321,6 +322,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { *
  • TWO_FACTOR_AUTH_ENABLED - TWO_FACTOR_AUTH_ENABLED
  • *
  • TWO_FACTOR_AUTH_DISABLED - TWO_FACTOR_AUTH_DISABLED
  • *
  • DELETED_LINKED_ACCOUNT - DELETED_LINKED_ACCOUNT
  • + *
  • DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT - DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT
  • *
  • CREATED_DESTINATION - CREATED_DESTINATION
  • *
  • DELETED_DESTINATION - DELETED_DESTINATION
  • *
  • CHANGED_DESTINATION - CHANGED_DESTINATION
  • @@ -358,7 +360,7 @@ public EventTypeStage ipAddress(@NotNull String ipAddress) { */ @java.lang.Override @JsonSetter("event_type") - public EventDescriptionStage eventType(@NotNull AuditLogEventEventType eventType) { + public EventDescriptionStage eventType(@NotNull EventTypeEnum eventType) { this.eventType = eventType; return this; } diff --git a/src/main/java/com/merge/api/resources/ticketing/types/AuditLogEventEventType.java b/src/main/java/com/merge/api/resources/ticketing/types/AuditLogEventEventType.java deleted file mode 100644 index 47ecf8bab..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/AuditLogEventEventType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventEventType.Deserializer.class) -public final class AuditLogEventEventType { - private final Object value; - - private final int type; - - private AuditLogEventEventType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EventTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventEventType && equalTo((AuditLogEventEventType) other); - } - - private boolean equalTo(AuditLogEventEventType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventEventType of(EventTypeEnum value) { - return new AuditLogEventEventType(value, 0); - } - - public static AuditLogEventEventType of(String value) { - return new AuditLogEventEventType(value, 1); - } - - public interface Visitor { - T visit(EventTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventEventType.class); - } - - @java.lang.Override - public AuditLogEventEventType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EventTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/AuditLogEventRole.java b/src/main/java/com/merge/api/resources/ticketing/types/AuditLogEventRole.java deleted file mode 100644 index b73d6378b..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/AuditLogEventRole.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AuditLogEventRole.Deserializer.class) -public final class AuditLogEventRole { - private final Object value; - - private final int type; - - private AuditLogEventRole(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((RoleEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditLogEventRole && equalTo((AuditLogEventRole) other); - } - - private boolean equalTo(AuditLogEventRole other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AuditLogEventRole of(RoleEnum value) { - return new AuditLogEventRole(value, 0); - } - - public static AuditLogEventRole of(String value) { - return new AuditLogEventRole(value, 1); - } - - public interface Visitor { - T visit(RoleEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AuditLogEventRole.class); - } - - @java.lang.Override - public AuditLogEventRole deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, RoleEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/Collection.java b/src/main/java/com/merge/api/resources/ticketing/types/Collection.java index 49d64e0b0..ec7b229ab 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/Collection.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/Collection.java @@ -35,15 +35,13 @@ public final class Collection { private final Optional description; - private final Optional collectionType; + private final Optional collectionType; private final Optional parentCollection; - private final Optional>> teams; - private final Optional remoteWasDeleted; - private final Optional accessLevel; + private final Optional accessLevel; private final Optional> fieldMappings; @@ -58,11 +56,10 @@ private Collection( Optional modifiedAt, Optional name, Optional description, - Optional collectionType, + Optional collectionType, Optional parentCollection, - Optional>> teams, Optional remoteWasDeleted, - Optional accessLevel, + Optional accessLevel, Optional> fieldMappings, Optional> remoteData, Map additionalProperties) { @@ -74,7 +71,6 @@ private Collection( this.description = description; this.collectionType = collectionType; this.parentCollection = parentCollection; - this.teams = teams; this.remoteWasDeleted = remoteWasDeleted; this.accessLevel = accessLevel; this.fieldMappings = fieldMappings; @@ -135,7 +131,7 @@ public Optional getDescription() { * */ @JsonProperty("collection_type") - public Optional getCollectionType() { + public Optional getCollectionType() { return collectionType; } @@ -147,11 +143,6 @@ public Optional getParentCollection() { return parentCollection; } - @JsonProperty("teams") - public Optional>> getTeams() { - return teams; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -169,7 +160,7 @@ public Optional getRemoteWasDeleted() { * */ @JsonProperty("access_level") - public Optional getAccessLevel() { + public Optional getAccessLevel() { return accessLevel; } @@ -203,7 +194,6 @@ private boolean equalTo(Collection other) { && description.equals(other.description) && collectionType.equals(other.collectionType) && parentCollection.equals(other.parentCollection) - && teams.equals(other.teams) && remoteWasDeleted.equals(other.remoteWasDeleted) && accessLevel.equals(other.accessLevel) && fieldMappings.equals(other.fieldMappings) @@ -221,7 +211,6 @@ public int hashCode() { this.description, this.collectionType, this.parentCollection, - this.teams, this.remoteWasDeleted, this.accessLevel, this.fieldMappings, @@ -251,15 +240,13 @@ public static final class Builder { private Optional description = Optional.empty(); - private Optional collectionType = Optional.empty(); + private Optional collectionType = Optional.empty(); private Optional parentCollection = Optional.empty(); - private Optional>> teams = Optional.empty(); - private Optional remoteWasDeleted = Optional.empty(); - private Optional accessLevel = Optional.empty(); + private Optional accessLevel = Optional.empty(); private Optional> fieldMappings = Optional.empty(); @@ -279,7 +266,6 @@ public Builder from(Collection other) { description(other.getDescription()); collectionType(other.getCollectionType()); parentCollection(other.getParentCollection()); - teams(other.getTeams()); remoteWasDeleted(other.getRemoteWasDeleted()); accessLevel(other.getAccessLevel()); fieldMappings(other.getFieldMappings()); @@ -354,12 +340,12 @@ public Builder description(String description) { } @JsonSetter(value = "collection_type", nulls = Nulls.SKIP) - public Builder collectionType(Optional collectionType) { + public Builder collectionType(Optional collectionType) { this.collectionType = collectionType; return this; } - public Builder collectionType(CollectionCollectionType collectionType) { + public Builder collectionType(CollectionTypeEnum collectionType) { this.collectionType = Optional.ofNullable(collectionType); return this; } @@ -375,17 +361,6 @@ public Builder parentCollection(CollectionParentCollection parentCollection) { return this; } - @JsonSetter(value = "teams", nulls = Nulls.SKIP) - public Builder teams(Optional>> teams) { - this.teams = teams; - return this; - } - - public Builder teams(List> teams) { - this.teams = Optional.ofNullable(teams); - return this; - } - @JsonSetter(value = "remote_was_deleted", nulls = Nulls.SKIP) public Builder remoteWasDeleted(Optional remoteWasDeleted) { this.remoteWasDeleted = remoteWasDeleted; @@ -398,12 +373,12 @@ public Builder remoteWasDeleted(Boolean remoteWasDeleted) { } @JsonSetter(value = "access_level", nulls = Nulls.SKIP) - public Builder accessLevel(Optional accessLevel) { + public Builder accessLevel(Optional accessLevel) { this.accessLevel = accessLevel; return this; } - public Builder accessLevel(CollectionAccessLevel accessLevel) { + public Builder accessLevel(AccessLevelEnum accessLevel) { this.accessLevel = Optional.ofNullable(accessLevel); return this; } @@ -440,7 +415,6 @@ public Collection build() { description, collectionType, parentCollection, - teams, remoteWasDeleted, accessLevel, fieldMappings, diff --git a/src/main/java/com/merge/api/resources/ticketing/types/CollectionAccessLevel.java b/src/main/java/com/merge/api/resources/ticketing/types/CollectionAccessLevel.java deleted file mode 100644 index 4601009df..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/CollectionAccessLevel.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = CollectionAccessLevel.Deserializer.class) -public final class CollectionAccessLevel { - private final Object value; - - private final int type; - - private CollectionAccessLevel(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AccessLevelEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CollectionAccessLevel && equalTo((CollectionAccessLevel) other); - } - - private boolean equalTo(CollectionAccessLevel other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static CollectionAccessLevel of(AccessLevelEnum value) { - return new CollectionAccessLevel(value, 0); - } - - public static CollectionAccessLevel of(String value) { - return new CollectionAccessLevel(value, 1); - } - - public interface Visitor { - T visit(AccessLevelEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(CollectionAccessLevel.class); - } - - @java.lang.Override - public CollectionAccessLevel deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AccessLevelEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/CollectionCollectionType.java b/src/main/java/com/merge/api/resources/ticketing/types/CollectionCollectionType.java deleted file mode 100644 index 8b36fef47..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/CollectionCollectionType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = CollectionCollectionType.Deserializer.class) -public final class CollectionCollectionType { - private final Object value; - - private final int type; - - private CollectionCollectionType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((CollectionTypeEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CollectionCollectionType && equalTo((CollectionCollectionType) other); - } - - private boolean equalTo(CollectionCollectionType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static CollectionCollectionType of(CollectionTypeEnum value) { - return new CollectionCollectionType(value, 0); - } - - public static CollectionCollectionType of(String value) { - return new CollectionCollectionType(value, 1); - } - - public interface Visitor { - T visit(CollectionTypeEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(CollectionCollectionType.class); - } - - @java.lang.Override - public CollectionCollectionType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, CollectionTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/CollectionParentCollection.java b/src/main/java/com/merge/api/resources/ticketing/types/CollectionParentCollection.java index 7d203a2a0..db10d2a6b 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/CollectionParentCollection.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/CollectionParentCollection.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((Team) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CollectionTeamsItem && equalTo((CollectionTeamsItem) other); - } - - private boolean equalTo(CollectionTeamsItem other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static CollectionTeamsItem of(String value) { - return new CollectionTeamsItem(value, 0); - } - - public static CollectionTeamsItem of(Team value) { - return new CollectionTeamsItem(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(Team value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(CollectionTeamsItem.class); - } - - @java.lang.Override - public CollectionTeamsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, Team.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/CommentContact.java b/src/main/java/com/merge/api/resources/ticketing/types/CommentContact.java index 0c2f2b525..5f879aa6f 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/CommentContact.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/CommentContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public CommentContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public CommentContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestContact.java b/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestContact.java index 7cb442d9c..e46d63980 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestContact.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public CommentRequestContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public CommentRequestContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestTicket.java b/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestTicket.java index 45ead0263..d48717dea 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestTicket.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestTicket.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public CommentRequestTicket deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public CommentRequestTicket deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestUser.java b/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestUser.java index a3b6fbe1e..802c4293a 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestUser.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/CommentRequestUser.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public CommentRequestUser deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public CommentRequestUser deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/CommentTicket.java b/src/main/java/com/merge/api/resources/ticketing/types/CommentTicket.java index 04c55f206..19af5f66a 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/CommentTicket.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/CommentTicket.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public CommentTicket deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public CommentTicket deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/CommentUser.java b/src/main/java/com/merge/api/resources/ticketing/types/CommentUser.java index a96797f14..beabbe435 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/CommentUser.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/CommentUser.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public CommentUser deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public CommentUser deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/ContactAccount.java b/src/main/java/com/merge/api/resources/ticketing/types/ContactAccount.java index f8b3236a7..d603540f5 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/ContactAccount.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/ContactAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ContactAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ContactAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/ContactRequestAccount.java b/src/main/java/com/merge/api/resources/ticketing/types/ContactRequestAccount.java index 9b1e7c261..e5c9c5b0b 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/ContactRequestAccount.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/ContactRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ContactRequestAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ContactRequestAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/EventTypeEnum.java b/src/main/java/com/merge/api/resources/ticketing/types/EventTypeEnum.java index 4adf46a40..e34864fc1 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/EventTypeEnum.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/EventTypeEnum.java @@ -24,6 +24,8 @@ public enum EventTypeEnum { DELETED_LINKED_ACCOUNT("DELETED_LINKED_ACCOUNT"), + DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT("DELETED_ALL_COMMON_MODELS_FOR_LINKED_ACCOUNT"), + CREATED_DESTINATION("CREATED_DESTINATION"), DELETED_DESTINATION("DELETED_DESTINATION"), diff --git a/src/main/java/com/merge/api/resources/ticketing/types/Issue.java b/src/main/java/com/merge/api/resources/ticketing/types/Issue.java index a36f4d7be..d361fb963 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/Issue.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/Issue.java @@ -26,7 +26,7 @@ public final class Issue { private final Optional id; - private final Optional status; + private final Optional status; private final String errorDescription; @@ -44,7 +44,7 @@ public final class Issue { private Issue( Optional id, - Optional status, + Optional status, String errorDescription, Optional> endUser, Optional firstIncidentTime, @@ -76,7 +76,7 @@ public Optional getId() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -167,9 +167,9 @@ public interface _FinalStage { _FinalStage id(String id); - _FinalStage status(Optional status); + _FinalStage status(Optional status); - _FinalStage status(IssueStatus status); + _FinalStage status(IssueStatusEnum status); _FinalStage endUser(Optional> endUser); @@ -206,7 +206,7 @@ public static final class Builder implements ErrorDescriptionStage, _FinalStage private Optional> endUser = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional id = Optional.empty(); @@ -309,14 +309,14 @@ public _FinalStage endUser(Optional> endUser) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage status(IssueStatus status) { + public _FinalStage status(IssueStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @java.lang.Override @JsonSetter(value = "status", nulls = Nulls.SKIP) - public _FinalStage status(Optional status) { + public _FinalStage status(Optional status) { this.status = status; return this; } diff --git a/src/main/java/com/merge/api/resources/ticketing/types/IssueStatus.java b/src/main/java/com/merge/api/resources/ticketing/types/IssueStatus.java deleted file mode 100644 index b55316dff..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/IssueStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = IssueStatus.Deserializer.class) -public final class IssueStatus { - private final Object value; - - private final int type; - - private IssueStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((IssueStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IssueStatus && equalTo((IssueStatus) other); - } - - private boolean equalTo(IssueStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static IssueStatus of(IssueStatusEnum value) { - return new IssueStatus(value, 0); - } - - public static IssueStatus of(String value) { - return new IssueStatus(value, 1); - } - - public interface Visitor { - T visit(IssueStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(IssueStatus.class); - } - - @java.lang.Override - public IssueStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, IssueStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/LastSyncResultEnum.java b/src/main/java/com/merge/api/resources/ticketing/types/LastSyncResultEnum.java new file mode 100644 index 000000000..441f38ddb --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/types/LastSyncResultEnum.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum LastSyncResultEnum { + SYNCING("SYNCING"), + + DONE("DONE"), + + FAILED("FAILED"), + + DISABLED("DISABLED"), + + PAUSED("PAUSED"), + + PARTIALLY_SYNCED("PARTIALLY_SYNCED"); + + private final String value; + + LastSyncResultEnum(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/MultipartFormFieldRequest.java b/src/main/java/com/merge/api/resources/ticketing/types/MultipartFormFieldRequest.java index 9ec4046cd..7430be5c8 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/MultipartFormFieldRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/MultipartFormFieldRequest.java @@ -25,7 +25,7 @@ public final class MultipartFormFieldRequest { private final String data; - private final Optional encoding; + private final Optional encoding; private final Optional fileName; @@ -36,7 +36,7 @@ public final class MultipartFormFieldRequest { private MultipartFormFieldRequest( String name, String data, - Optional encoding, + Optional encoding, Optional fileName, Optional contentType, Map additionalProperties) { @@ -73,7 +73,7 @@ public String getData() { * */ @JsonProperty("encoding") - public Optional getEncoding() { + public Optional getEncoding() { return encoding; } @@ -139,9 +139,9 @@ public interface DataStage { public interface _FinalStage { MultipartFormFieldRequest build(); - _FinalStage encoding(Optional encoding); + _FinalStage encoding(Optional encoding); - _FinalStage encoding(MultipartFormFieldRequestEncoding encoding); + _FinalStage encoding(EncodingEnum encoding); _FinalStage fileName(Optional fileName); @@ -162,7 +162,7 @@ public static final class Builder implements NameStage, DataStage, _FinalStage { private Optional fileName = Optional.empty(); - private Optional encoding = Optional.empty(); + private Optional encoding = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -245,14 +245,14 @@ public _FinalStage fileName(Optional fileName) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage encoding(MultipartFormFieldRequestEncoding encoding) { + public _FinalStage encoding(EncodingEnum encoding) { this.encoding = Optional.ofNullable(encoding); return this; } @java.lang.Override @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { + public _FinalStage encoding(Optional encoding) { this.encoding = encoding; return this; } diff --git a/src/main/java/com/merge/api/resources/ticketing/types/MultipartFormFieldRequestEncoding.java b/src/main/java/com/merge/api/resources/ticketing/types/MultipartFormFieldRequestEncoding.java deleted file mode 100644 index be3138383..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/MultipartFormFieldRequestEncoding.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = MultipartFormFieldRequestEncoding.Deserializer.class) -public final class MultipartFormFieldRequestEncoding { - private final Object value; - - private final int type; - - private MultipartFormFieldRequestEncoding(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((EncodingEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MultipartFormFieldRequestEncoding && equalTo((MultipartFormFieldRequestEncoding) other); - } - - private boolean equalTo(MultipartFormFieldRequestEncoding other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static MultipartFormFieldRequestEncoding of(EncodingEnum value) { - return new MultipartFormFieldRequestEncoding(value, 0); - } - - public static MultipartFormFieldRequestEncoding of(String value) { - return new MultipartFormFieldRequestEncoding(value, 1); - } - - public interface Visitor { - T visit(EncodingEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(MultipartFormFieldRequestEncoding.class); - } - - @java.lang.Override - public MultipartFormFieldRequestEncoding deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, EncodingEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/PatchedTicketRequest.java b/src/main/java/com/merge/api/resources/ticketing/types/PatchedTicketRequest.java index 048a5ea7d..4256ebb4a 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/PatchedTicketRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/PatchedTicketRequest.java @@ -33,7 +33,7 @@ public final class PatchedTicketRequest { private final Optional dueDate; - private final Optional status; + private final Optional status; private final Optional description; @@ -55,7 +55,7 @@ public final class PatchedTicketRequest { private final Optional ticketUrl; - private final Optional priority; + private final Optional priority; private final Optional> integrationParams; @@ -71,7 +71,7 @@ private PatchedTicketRequest( Optional>> assignedTeams, Optional creator, Optional dueDate, - Optional status, + Optional status, Optional description, Optional>> collections, Optional ticketType, @@ -82,7 +82,7 @@ private PatchedTicketRequest( Optional>> roles, Optional completedAt, Optional ticketUrl, - Optional priority, + Optional priority, Optional> integrationParams, Optional> linkedAccountParams, Optional> remoteFields, @@ -119,7 +119,7 @@ public Optional getName() { } /** - * @return The individual Users who are assigned to this ticket. This does not include Users who just have view access to this ticket. + * @return The individual Users who are assigned to this ticket. This does not include Users who just have view access to this ticket. To fetch all Users and Teams that can access the ticket, use the GET /tickets/{ticket_id}/viewers endpoint. */ @JsonProperty("assignees") public Optional>> getAssignees() { @@ -127,7 +127,7 @@ public Optional>> getAssignees() { } /** - * @return The Teams that are assigned to this ticket. This does not include Teams who just have view access to this ticket. + * @return The Teams that are assigned to this ticket. This does not include Teams who just have view access to this ticket. To fetch all Users and Teams that can access this ticket, use the GET /tickets/{ticket_id}/viewers endpoint. */ @JsonProperty("assigned_teams") public Optional>> getAssignedTeams() { @@ -160,7 +160,7 @@ public Optional getDueDate() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -248,7 +248,7 @@ public Optional getTicketUrl() { * */ @JsonProperty("priority") - public Optional getPriority() { + public Optional getPriority() { return priority; } @@ -347,7 +347,7 @@ public static final class Builder { private Optional dueDate = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional description = Optional.empty(); @@ -369,7 +369,7 @@ public static final class Builder { private Optional ticketUrl = Optional.empty(); - private Optional priority = Optional.empty(); + private Optional priority = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -462,12 +462,12 @@ public Builder dueDate(OffsetDateTime dueDate) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(PatchedTicketRequestStatus status) { + public Builder status(TicketStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -583,12 +583,12 @@ public Builder ticketUrl(String ticketUrl) { } @JsonSetter(value = "priority", nulls = Nulls.SKIP) - public Builder priority(Optional priority) { + public Builder priority(Optional priority) { this.priority = priority; return this; } - public Builder priority(PatchedTicketRequestPriority priority) { + public Builder priority(PriorityEnum priority) { this.priority = Optional.ofNullable(priority); return this; } diff --git a/src/main/java/com/merge/api/resources/ticketing/types/PatchedTicketRequestPriority.java b/src/main/java/com/merge/api/resources/ticketing/types/PatchedTicketRequestPriority.java deleted file mode 100644 index 716e0ca18..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/PatchedTicketRequestPriority.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PatchedTicketRequestPriority.Deserializer.class) -public final class PatchedTicketRequestPriority { - private final Object value; - - private final int type; - - private PatchedTicketRequestPriority(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PriorityEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PatchedTicketRequestPriority && equalTo((PatchedTicketRequestPriority) other); - } - - private boolean equalTo(PatchedTicketRequestPriority other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PatchedTicketRequestPriority of(PriorityEnum value) { - return new PatchedTicketRequestPriority(value, 0); - } - - public static PatchedTicketRequestPriority of(String value) { - return new PatchedTicketRequestPriority(value, 1); - } - - public interface Visitor { - T visit(PriorityEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PatchedTicketRequestPriority.class); - } - - @java.lang.Override - public PatchedTicketRequestPriority deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PriorityEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/PatchedTicketRequestStatus.java b/src/main/java/com/merge/api/resources/ticketing/types/PatchedTicketRequestStatus.java deleted file mode 100644 index ed532e9f4..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/PatchedTicketRequestStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = PatchedTicketRequestStatus.Deserializer.class) -public final class PatchedTicketRequestStatus { - private final Object value; - - private final int type; - - private PatchedTicketRequestStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TicketStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PatchedTicketRequestStatus && equalTo((PatchedTicketRequestStatus) other); - } - - private boolean equalTo(PatchedTicketRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static PatchedTicketRequestStatus of(TicketStatusEnum value) { - return new PatchedTicketRequestStatus(value, 0); - } - - public static PatchedTicketRequestStatus of(String value) { - return new PatchedTicketRequestStatus(value, 1); - } - - public interface Visitor { - T visit(TicketStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(PatchedTicketRequestStatus.class); - } - - @java.lang.Override - public PatchedTicketRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TicketStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldApiCoverage.java b/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldApiCoverage.java index 9c6a4546f..ff15b0ebd 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldApiCoverage.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldApiCoverage.java @@ -28,6 +28,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((int) this.value); @@ -77,7 +78,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public RemoteFieldApiCoverage deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); if (value instanceof Integer) { return of((Integer) value); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldClass.java b/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldClass.java index 207e7f3b8..acfedc657 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldClass.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldClass.java @@ -33,9 +33,9 @@ public final class RemoteFieldClass { private final Optional isRequired; - private final Optional fieldType; + private final Optional fieldType; - private final Optional fieldFormat; + private final Optional fieldFormat; private final Optional> fieldChoices; @@ -50,8 +50,8 @@ private RemoteFieldClass( Optional description, Optional isCustom, Optional isRequired, - Optional fieldType, - Optional fieldFormat, + Optional fieldType, + Optional fieldFormat, Optional> fieldChoices, Optional itemSchema, Map additionalProperties) { @@ -99,12 +99,12 @@ public Optional getIsRequired() { } @JsonProperty("field_type") - public Optional getFieldType() { + public Optional getFieldType() { return fieldType; } @JsonProperty("field_format") - public Optional getFieldFormat() { + public Optional getFieldFormat() { return fieldFormat; } @@ -180,9 +180,9 @@ public static final class Builder { private Optional isRequired = Optional.empty(); - private Optional fieldType = Optional.empty(); + private Optional fieldType = Optional.empty(); - private Optional fieldFormat = Optional.empty(); + private Optional fieldFormat = Optional.empty(); private Optional> fieldChoices = Optional.empty(); @@ -274,23 +274,23 @@ public Builder isRequired(Boolean isRequired) { } @JsonSetter(value = "field_type", nulls = Nulls.SKIP) - public Builder fieldType(Optional fieldType) { + public Builder fieldType(Optional fieldType) { this.fieldType = fieldType; return this; } - public Builder fieldType(RemoteFieldClassFieldType fieldType) { + public Builder fieldType(FieldTypeEnum fieldType) { this.fieldType = Optional.ofNullable(fieldType); return this; } @JsonSetter(value = "field_format", nulls = Nulls.SKIP) - public Builder fieldFormat(Optional fieldFormat) { + public Builder fieldFormat(Optional fieldFormat) { this.fieldFormat = fieldFormat; return this; } - public Builder fieldFormat(RemoteFieldClassFieldFormat fieldFormat) { + public Builder fieldFormat(FieldFormatEnum fieldFormat) { this.fieldFormat = Optional.ofNullable(fieldFormat); return this; } diff --git a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldClassFieldFormat.java b/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldClassFieldFormat.java deleted file mode 100644 index 144931887..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldClassFieldFormat.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RemoteFieldClassFieldFormat.Deserializer.class) -public final class RemoteFieldClassFieldFormat { - private final Object value; - - private final int type; - - private RemoteFieldClassFieldFormat(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((FieldFormatEnum) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RemoteFieldClassFieldFormat && equalTo((RemoteFieldClassFieldFormat) other); - } - - private boolean equalTo(RemoteFieldClassFieldFormat other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RemoteFieldClassFieldFormat of(String value) { - return new RemoteFieldClassFieldFormat(value, 0); - } - - public static RemoteFieldClassFieldFormat of(FieldFormatEnum value) { - return new RemoteFieldClassFieldFormat(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(FieldFormatEnum value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RemoteFieldClassFieldFormat.class); - } - - @java.lang.Override - public RemoteFieldClassFieldFormat deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FieldFormatEnum.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldClassFieldType.java b/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldClassFieldType.java deleted file mode 100644 index 0acdd7825..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldClassFieldType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RemoteFieldClassFieldType.Deserializer.class) -public final class RemoteFieldClassFieldType { - private final Object value; - - private final int type; - - private RemoteFieldClassFieldType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((FieldTypeEnum) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RemoteFieldClassFieldType && equalTo((RemoteFieldClassFieldType) other); - } - - private boolean equalTo(RemoteFieldClassFieldType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RemoteFieldClassFieldType of(String value) { - return new RemoteFieldClassFieldType(value, 0); - } - - public static RemoteFieldClassFieldType of(FieldTypeEnum value) { - return new RemoteFieldClassFieldType(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(FieldTypeEnum value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RemoteFieldClassFieldType.class); - } - - @java.lang.Override - public RemoteFieldClassFieldType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FieldTypeEnum.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldRemoteFieldClass.java b/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldRemoteFieldClass.java index f41cfe2ce..555183885 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldRemoteFieldClass.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldRemoteFieldClass.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer value; + private final Optional value; private final Map additionalProperties; private RemoteFieldRequest( RemoteFieldRequestRemoteFieldClass remoteFieldClass, - Optional value, + Optional value, Map additionalProperties) { this.remoteFieldClass = remoteFieldClass; this.value = value; @@ -42,7 +43,7 @@ public RemoteFieldRequestRemoteFieldClass getRemoteFieldClass() { } @JsonProperty("value") - public Optional getValue() { + public Optional getValue() { return value; } @@ -84,16 +85,16 @@ public interface RemoteFieldClassStage { public interface _FinalStage { RemoteFieldRequest build(); - _FinalStage value(Optional value); + _FinalStage value(Optional value); - _FinalStage value(String value); + _FinalStage value(JsonNode value); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements RemoteFieldClassStage, _FinalStage { private RemoteFieldRequestRemoteFieldClass remoteFieldClass; - private Optional value = Optional.empty(); + private Optional value = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -115,14 +116,14 @@ public _FinalStage remoteFieldClass(@NotNull RemoteFieldRequestRemoteFieldClass } @java.lang.Override - public _FinalStage value(String value) { + public _FinalStage value(JsonNode value) { this.value = Optional.ofNullable(value); return this; } @java.lang.Override @JsonSetter(value = "value", nulls = Nulls.SKIP) - public _FinalStage value(Optional value) { + public _FinalStage value(Optional value) { this.value = value; return this; } diff --git a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldRequestRemoteFieldClass.java b/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldRequestRemoteFieldClass.java index 167cd0de0..5c16f2258 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldRequestRemoteFieldClass.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/RemoteFieldRequestRemoteFieldClass.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -79,7 +80,7 @@ static final class Deserializer extends StdDeserializer name; - private final Optional>> ticketActions; + private final Optional> ticketActions; - private final Optional ticketAccess; + private final Optional ticketAccess; private final Optional remoteWasDeleted; @@ -51,8 +51,8 @@ private Role( Optional createdAt, Optional modifiedAt, Optional name, - Optional>> ticketActions, - Optional ticketAccess, + Optional> ticketActions, + Optional ticketAccess, Optional remoteWasDeleted, Optional> fieldMappings, Optional> remoteData, @@ -111,7 +111,7 @@ public Optional getName() { * @return The set of actions that a User with this Role can perform. Possible enum values include: VIEW, CREATE, EDIT, DELETE, CLOSE, and ASSIGN. */ @JsonProperty("ticket_actions") - public Optional>> getTicketActions() { + public Optional> getTicketActions() { return ticketActions; } @@ -124,7 +124,7 @@ public Optional>> getTicketActions() { * */ @JsonProperty("ticket_access") - public Optional getTicketAccess() { + public Optional getTicketAccess() { return ticketAccess; } @@ -206,9 +206,9 @@ public static final class Builder { private Optional name = Optional.empty(); - private Optional>> ticketActions = Optional.empty(); + private Optional> ticketActions = Optional.empty(); - private Optional ticketAccess = Optional.empty(); + private Optional ticketAccess = Optional.empty(); private Optional remoteWasDeleted = Optional.empty(); @@ -291,23 +291,23 @@ public Builder name(String name) { } @JsonSetter(value = "ticket_actions", nulls = Nulls.SKIP) - public Builder ticketActions(Optional>> ticketActions) { + public Builder ticketActions(Optional> ticketActions) { this.ticketActions = ticketActions; return this; } - public Builder ticketActions(List> ticketActions) { + public Builder ticketActions(List ticketActions) { this.ticketActions = Optional.ofNullable(ticketActions); return this; } @JsonSetter(value = "ticket_access", nulls = Nulls.SKIP) - public Builder ticketAccess(Optional ticketAccess) { + public Builder ticketAccess(Optional ticketAccess) { this.ticketAccess = ticketAccess; return this; } - public Builder ticketAccess(RoleTicketAccess ticketAccess) { + public Builder ticketAccess(TicketAccessEnum ticketAccess) { this.ticketAccess = Optional.ofNullable(ticketAccess); return this; } diff --git a/src/main/java/com/merge/api/resources/ticketing/types/RoleTicketAccess.java b/src/main/java/com/merge/api/resources/ticketing/types/RoleTicketAccess.java deleted file mode 100644 index f7516f158..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/RoleTicketAccess.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RoleTicketAccess.Deserializer.class) -public final class RoleTicketAccess { - private final Object value; - - private final int type; - - private RoleTicketAccess(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((TicketAccessEnum) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RoleTicketAccess && equalTo((RoleTicketAccess) other); - } - - private boolean equalTo(RoleTicketAccess other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RoleTicketAccess of(String value) { - return new RoleTicketAccess(value, 0); - } - - public static RoleTicketAccess of(TicketAccessEnum value) { - return new RoleTicketAccess(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(TicketAccessEnum value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RoleTicketAccess.class); - } - - @java.lang.Override - public RoleTicketAccess deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TicketAccessEnum.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/RoleTicketActionsItem.java b/src/main/java/com/merge/api/resources/ticketing/types/RoleTicketActionsItem.java deleted file mode 100644 index 936aee845..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/RoleTicketActionsItem.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = RoleTicketActionsItem.Deserializer.class) -public final class RoleTicketActionsItem { - private final Object value; - - private final int type; - - private RoleTicketActionsItem(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((TicketActionsEnum) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RoleTicketActionsItem && equalTo((RoleTicketActionsItem) other); - } - - private boolean equalTo(RoleTicketActionsItem other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static RoleTicketActionsItem of(String value) { - return new RoleTicketActionsItem(value, 0); - } - - public static RoleTicketActionsItem of(TicketActionsEnum value) { - return new RoleTicketActionsItem(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(TicketActionsEnum value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(RoleTicketActionsItem.class); - } - - @java.lang.Override - public RoleTicketActionsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TicketActionsEnum.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/StatusFd5Enum.java b/src/main/java/com/merge/api/resources/ticketing/types/StatusFd5Enum.java new file mode 100644 index 000000000..98b01bcf9 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/types/StatusFd5Enum.java @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum StatusFd5Enum { + SYNCING("SYNCING"), + + DONE("DONE"), + + FAILED("FAILED"), + + DISABLED("DISABLED"), + + PAUSED("PAUSED"), + + PARTIALLY_SYNCED("PARTIALLY_SYNCED"); + + private final String value; + + StatusFd5Enum(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/SyncStatus.java b/src/main/java/com/merge/api/resources/ticketing/types/SyncStatus.java index 2d4470222..2be91f837 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/SyncStatus.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/SyncStatus.java @@ -30,7 +30,11 @@ public final class SyncStatus { private final Optional nextSyncStart; - private final SyncStatusStatusEnum status; + private final Optional lastSyncResult; + + private final Optional lastSyncFinished; + + private final StatusFd5Enum status; private final boolean isInitialSync; @@ -43,7 +47,9 @@ private SyncStatus( String modelId, Optional lastSyncStart, Optional nextSyncStart, - SyncStatusStatusEnum status, + Optional lastSyncResult, + Optional lastSyncFinished, + StatusFd5Enum status, boolean isInitialSync, Optional selectiveSyncConfigurationsUsage, Map additionalProperties) { @@ -51,6 +57,8 @@ private SyncStatus( this.modelId = modelId; this.lastSyncStart = lastSyncStart; this.nextSyncStart = nextSyncStart; + this.lastSyncResult = lastSyncResult; + this.lastSyncFinished = lastSyncFinished; this.status = status; this.isInitialSync = isInitialSync; this.selectiveSyncConfigurationsUsage = selectiveSyncConfigurationsUsage; @@ -77,8 +85,18 @@ public Optional getNextSyncStart() { return nextSyncStart; } + @JsonProperty("last_sync_result") + public Optional getLastSyncResult() { + return lastSyncResult; + } + + @JsonProperty("last_sync_finished") + public Optional getLastSyncFinished() { + return lastSyncFinished; + } + @JsonProperty("status") - public SyncStatusStatusEnum getStatus() { + public StatusFd5Enum getStatus() { return status; } @@ -108,6 +126,8 @@ private boolean equalTo(SyncStatus other) { && modelId.equals(other.modelId) && lastSyncStart.equals(other.lastSyncStart) && nextSyncStart.equals(other.nextSyncStart) + && lastSyncResult.equals(other.lastSyncResult) + && lastSyncFinished.equals(other.lastSyncFinished) && status.equals(other.status) && isInitialSync == other.isInitialSync && selectiveSyncConfigurationsUsage.equals(other.selectiveSyncConfigurationsUsage); @@ -120,6 +140,8 @@ public int hashCode() { this.modelId, this.lastSyncStart, this.nextSyncStart, + this.lastSyncResult, + this.lastSyncFinished, this.status, this.isInitialSync, this.selectiveSyncConfigurationsUsage); @@ -145,7 +167,7 @@ public interface ModelIdStage { } public interface StatusStage { - IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status); + IsInitialSyncStage status(@NotNull StatusFd5Enum status); } public interface IsInitialSyncStage { @@ -163,6 +185,14 @@ public interface _FinalStage { _FinalStage nextSyncStart(OffsetDateTime nextSyncStart); + _FinalStage lastSyncResult(Optional lastSyncResult); + + _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult); + + _FinalStage lastSyncFinished(Optional lastSyncFinished); + + _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished); + _FinalStage selectiveSyncConfigurationsUsage( Optional selectiveSyncConfigurationsUsage); @@ -177,12 +207,16 @@ public static final class Builder private String modelId; - private SyncStatusStatusEnum status; + private StatusFd5Enum status; private boolean isInitialSync; private Optional selectiveSyncConfigurationsUsage = Optional.empty(); + private Optional lastSyncFinished = Optional.empty(); + + private Optional lastSyncResult = Optional.empty(); + private Optional nextSyncStart = Optional.empty(); private Optional lastSyncStart = Optional.empty(); @@ -198,6 +232,8 @@ public Builder from(SyncStatus other) { modelId(other.getModelId()); lastSyncStart(other.getLastSyncStart()); nextSyncStart(other.getNextSyncStart()); + lastSyncResult(other.getLastSyncResult()); + lastSyncFinished(other.getLastSyncFinished()); status(other.getStatus()); isInitialSync(other.getIsInitialSync()); selectiveSyncConfigurationsUsage(other.getSelectiveSyncConfigurationsUsage()); @@ -220,7 +256,7 @@ public StatusStage modelId(@NotNull String modelId) { @java.lang.Override @JsonSetter("status") - public IsInitialSyncStage status(@NotNull SyncStatusStatusEnum status) { + public IsInitialSyncStage status(@NotNull StatusFd5Enum status) { this.status = status; return this; } @@ -247,6 +283,32 @@ public _FinalStage selectiveSyncConfigurationsUsage( return this; } + @java.lang.Override + public _FinalStage lastSyncFinished(OffsetDateTime lastSyncFinished) { + this.lastSyncFinished = Optional.ofNullable(lastSyncFinished); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_finished", nulls = Nulls.SKIP) + public _FinalStage lastSyncFinished(Optional lastSyncFinished) { + this.lastSyncFinished = lastSyncFinished; + return this; + } + + @java.lang.Override + public _FinalStage lastSyncResult(LastSyncResultEnum lastSyncResult) { + this.lastSyncResult = Optional.ofNullable(lastSyncResult); + return this; + } + + @java.lang.Override + @JsonSetter(value = "last_sync_result", nulls = Nulls.SKIP) + public _FinalStage lastSyncResult(Optional lastSyncResult) { + this.lastSyncResult = lastSyncResult; + return this; + } + @java.lang.Override public _FinalStage nextSyncStart(OffsetDateTime nextSyncStart) { this.nextSyncStart = Optional.ofNullable(nextSyncStart); @@ -280,6 +342,8 @@ public SyncStatus build() { modelId, lastSyncStart, nextSyncStart, + lastSyncResult, + lastSyncFinished, status, isInitialSync, selectiveSyncConfigurationsUsage, diff --git a/src/main/java/com/merge/api/resources/ticketing/types/SyncStatusStatusEnum.java b/src/main/java/com/merge/api/resources/ticketing/types/SyncStatusStatusEnum.java deleted file mode 100644 index caf1b260f..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/SyncStatusStatusEnum.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SyncStatusStatusEnum { - SYNCING("SYNCING"), - - DONE("DONE"), - - FAILED("FAILED"), - - DISABLED("DISABLED"), - - PAUSED("PAUSED"), - - PARTIALLY_SYNCED("PARTIALLY_SYNCED"); - - private final String value; - - SyncStatusStatusEnum(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/Ticket.java b/src/main/java/com/merge/api/resources/ticketing/types/Ticket.java index 561dee691..bfc196d24 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/Ticket.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/Ticket.java @@ -41,7 +41,7 @@ public final class Ticket { private final Optional dueDate; - private final Optional status; + private final Optional status; private final Optional description; @@ -71,7 +71,7 @@ public final class Ticket { private final Optional ticketUrl; - private final Optional priority; + private final Optional priority; private final Optional> fieldMappings; @@ -91,7 +91,7 @@ private Ticket( Optional>> assignedTeams, Optional creator, Optional dueDate, - Optional status, + Optional status, Optional description, Optional>> collections, Optional ticketType, @@ -106,7 +106,7 @@ private Ticket( Optional completedAt, Optional remoteWasDeleted, Optional ticketUrl, - Optional priority, + Optional priority, Optional> fieldMappings, Optional> remoteData, Optional> remoteFields, @@ -180,7 +180,7 @@ public Optional getName() { } /** - * @return The individual Users who are assigned to this ticket. This does not include Users who just have view access to this ticket. + * @return The individual Users who are assigned to this ticket. This does not include Users who just have view access to this ticket. To fetch all Users and Teams that can access the ticket, use the GET /tickets/{ticket_id}/viewers endpoint. */ @JsonProperty("assignees") public Optional>> getAssignees() { @@ -188,7 +188,7 @@ public Optional>> getAssignees() { } /** - * @return The Teams that are assigned to this ticket. This does not include Teams who just have view access to this ticket. + * @return The Teams that are assigned to this ticket. This does not include Teams who just have view access to this ticket. To fetch all Users and Teams that can access this ticket, use the GET /tickets/{ticket_id}/viewers endpoint. */ @JsonProperty("assigned_teams") public Optional>> getAssignedTeams() { @@ -221,7 +221,7 @@ public Optional getDueDate() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -338,7 +338,7 @@ public Optional getTicketUrl() { * */ @JsonProperty("priority") - public Optional getPriority() { + public Optional getPriority() { return priority; } @@ -461,7 +461,7 @@ public static final class Builder { private Optional dueDate = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional description = Optional.empty(); @@ -491,7 +491,7 @@ public static final class Builder { private Optional ticketUrl = Optional.empty(); - private Optional priority = Optional.empty(); + private Optional priority = Optional.empty(); private Optional> fieldMappings = Optional.empty(); @@ -636,12 +636,12 @@ public Builder dueDate(OffsetDateTime dueDate) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(TicketStatus status) { + public Builder status(TicketStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -801,12 +801,12 @@ public Builder ticketUrl(String ticketUrl) { } @JsonSetter(value = "priority", nulls = Nulls.SKIP) - public Builder priority(Optional priority) { + public Builder priority(Optional priority) { this.priority = priority; return this; } - public Builder priority(TicketPriority priority) { + public Builder priority(PriorityEnum priority) { this.priority = Optional.ofNullable(priority); return this; } diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketAccount.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketAccount.java index b8de9868d..dfdc2b036 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketAccount.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TicketAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketAssignedTeamsItem.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketAssignedTeamsItem.java index f86af12c0..0619e6e04 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketAssignedTeamsItem.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketAssignedTeamsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer } @java.lang.Override - public TicketAssignedTeamsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketAssignedTeamsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketAssigneesItem.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketAssigneesItem.java index ac19f3c6a..1db4a59ba 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketAssigneesItem.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketAssigneesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TicketAssigneesItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketAssigneesItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketAttachmentsItem.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketAttachmentsItem.java index 9ea890ef8..b82b9953f 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketAttachmentsItem.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketAttachmentsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TicketAttachmentsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketAttachmentsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketCollectionsItem.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketCollectionsItem.java index 2db51ea5f..e5f8b0fdb 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketCollectionsItem.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketCollectionsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TicketCollectionsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketCollectionsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketContact.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketContact.java index 44dc32a38..a31582112 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketContact.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketContact.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TicketContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketCreator.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketCreator.java index 6b72e6c9f..312ba1c06 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketCreator.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketCreator.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TicketCreator deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketCreator deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketParentTicket.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketParentTicket.java index fff5aab0c..fae48480c 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketParentTicket.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketParentTicket.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TicketParentTicket deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketParentTicket deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketPriority.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketPriority.java deleted file mode 100644 index 8f7ea3774..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketPriority.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TicketPriority.Deserializer.class) -public final class TicketPriority { - private final Object value; - - private final int type; - - private TicketPriority(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PriorityEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TicketPriority && equalTo((TicketPriority) other); - } - - private boolean equalTo(TicketPriority other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TicketPriority of(PriorityEnum value) { - return new TicketPriority(value, 0); - } - - public static TicketPriority of(String value) { - return new TicketPriority(value, 1); - } - - public interface Visitor { - T visit(PriorityEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TicketPriority.class); - } - - @java.lang.Override - public TicketPriority deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PriorityEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequest.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequest.java index 122774387..2fcf548c2 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequest.java @@ -33,7 +33,7 @@ public final class TicketRequest { private final Optional dueDate; - private final Optional status; + private final Optional status; private final Optional description; @@ -57,7 +57,7 @@ public final class TicketRequest { private final Optional ticketUrl; - private final Optional priority; + private final Optional priority; private final Optional> integrationParams; @@ -73,7 +73,7 @@ private TicketRequest( Optional>> assignedTeams, Optional creator, Optional dueDate, - Optional status, + Optional status, Optional description, Optional>> collections, Optional ticketType, @@ -85,7 +85,7 @@ private TicketRequest( Optional>> roles, Optional completedAt, Optional ticketUrl, - Optional priority, + Optional priority, Optional> integrationParams, Optional> linkedAccountParams, Optional> remoteFields, @@ -123,7 +123,7 @@ public Optional getName() { } /** - * @return The individual Users who are assigned to this ticket. This does not include Users who just have view access to this ticket. + * @return The individual Users who are assigned to this ticket. This does not include Users who just have view access to this ticket. To fetch all Users and Teams that can access the ticket, use the GET /tickets/{ticket_id}/viewers endpoint. */ @JsonProperty("assignees") public Optional>> getAssignees() { @@ -131,7 +131,7 @@ public Optional>> getAssignees() { } /** - * @return The Teams that are assigned to this ticket. This does not include Teams who just have view access to this ticket. + * @return The Teams that are assigned to this ticket. This does not include Teams who just have view access to this ticket. To fetch all Users and Teams that can access this ticket, use the GET /tickets/{ticket_id}/viewers endpoint. */ @JsonProperty("assigned_teams") public Optional>> getAssignedTeams() { @@ -164,7 +164,7 @@ public Optional getDueDate() { * */ @JsonProperty("status") - public Optional getStatus() { + public Optional getStatus() { return status; } @@ -257,7 +257,7 @@ public Optional getTicketUrl() { * */ @JsonProperty("priority") - public Optional getPriority() { + public Optional getPriority() { return priority; } @@ -358,7 +358,7 @@ public static final class Builder { private Optional dueDate = Optional.empty(); - private Optional status = Optional.empty(); + private Optional status = Optional.empty(); private Optional description = Optional.empty(); @@ -382,7 +382,7 @@ public static final class Builder { private Optional ticketUrl = Optional.empty(); - private Optional priority = Optional.empty(); + private Optional priority = Optional.empty(); private Optional> integrationParams = Optional.empty(); @@ -476,12 +476,12 @@ public Builder dueDate(OffsetDateTime dueDate) { } @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { + public Builder status(Optional status) { this.status = status; return this; } - public Builder status(TicketRequestStatus status) { + public Builder status(TicketStatusEnum status) { this.status = Optional.ofNullable(status); return this; } @@ -608,12 +608,12 @@ public Builder ticketUrl(String ticketUrl) { } @JsonSetter(value = "priority", nulls = Nulls.SKIP) - public Builder priority(Optional priority) { + public Builder priority(Optional priority) { this.priority = priority; return this; } - public Builder priority(TicketRequestPriority priority) { + public Builder priority(PriorityEnum priority) { this.priority = Optional.ofNullable(priority); return this; } diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestAccount.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestAccount.java index 2b3e79031..c63213129 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestAccount.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestAccount.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TicketRequestAccount deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketRequestAccount deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestAssignedTeamsItem.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestAssignedTeamsItem.java index 341b39fee..81cd5fe63 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestAssignedTeamsItem.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestAssignedTeamsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,8 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TicketRequestContact deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketRequestContact deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestCreator.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestCreator.java index 81b1ea3a3..d3666fbc7 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestCreator.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestCreator.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public TicketRequestCreator deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public TicketRequestCreator deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestParentTicket.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestParentTicket.java index 5888ade95..661e07841 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestParentTicket.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestParentTicket.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((PriorityEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TicketRequestPriority && equalTo((TicketRequestPriority) other); - } - - private boolean equalTo(TicketRequestPriority other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TicketRequestPriority of(PriorityEnum value) { - return new TicketRequestPriority(value, 0); - } - - public static TicketRequestPriority of(String value) { - return new TicketRequestPriority(value, 1); - } - - public interface Visitor { - T visit(PriorityEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TicketRequestPriority.class); - } - - @java.lang.Override - public TicketRequestPriority deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PriorityEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestStatus.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestStatus.java deleted file mode 100644 index 603c91f71..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketRequestStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TicketRequestStatus.Deserializer.class) -public final class TicketRequestStatus { - private final Object value; - - private final int type; - - private TicketRequestStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TicketStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TicketRequestStatus && equalTo((TicketRequestStatus) other); - } - - private boolean equalTo(TicketRequestStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TicketRequestStatus of(TicketStatusEnum value) { - return new TicketRequestStatus(value, 0); - } - - public static TicketRequestStatus of(String value) { - return new TicketRequestStatus(value, 1); - } - - public interface Visitor { - T visit(TicketStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TicketRequestStatus.class); - } - - @java.lang.Override - public TicketRequestStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TicketStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/TicketStatus.java b/src/main/java/com/merge/api/resources/ticketing/types/TicketStatus.java deleted file mode 100644 index 67bd18c24..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/types/TicketStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.merge.api.core.ObjectMappers; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = TicketStatus.Deserializer.class) -public final class TicketStatus { - private final Object value; - - private final int type; - - private TicketStatus(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((TicketStatusEnum) this.value); - } else if (this.type == 1) { - return visitor.visit((String) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TicketStatus && equalTo((TicketStatus) other); - } - - private boolean equalTo(TicketStatus other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static TicketStatus of(TicketStatusEnum value) { - return new TicketStatus(value, 0); - } - - public static TicketStatus of(String value) { - return new TicketStatus(value, 1); - } - - public interface Visitor { - T visit(TicketStatusEnum value); - - T visit(String value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(TicketStatus.class); - } - - @java.lang.Override - public TicketStatus deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TicketStatusEnum.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/types/UserRolesItem.java b/src/main/java/com/merge/api/resources/ticketing/types/UserRolesItem.java index 512e7f7ac..b88a7ca4b 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/UserRolesItem.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/UserRolesItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public UserRolesItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public UserRolesItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/UserTeamsItem.java b/src/main/java/com/merge/api/resources/ticketing/types/UserTeamsItem.java index 1f986f204..61e82ff8e 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/UserTeamsItem.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/UserTeamsItem.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public UserTeamsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public UserTeamsItem deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/ViewerTeam.java b/src/main/java/com/merge/api/resources/ticketing/types/ViewerTeam.java index 6ddd8dbf8..3e51f7a54 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/ViewerTeam.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/ViewerTeam.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ViewerTeam deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ViewerTeam deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/types/ViewerUser.java b/src/main/java/com/merge/api/resources/ticketing/types/ViewerUser.java index 02c64b78b..f9cab3545 100644 --- a/src/main/java/com/merge/api/resources/ticketing/types/ViewerUser.java +++ b/src/main/java/com/merge/api/resources/ticketing/types/ViewerUser.java @@ -29,6 +29,7 @@ public Object get() { return this.value; } + @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { return visitor.visit((String) this.value); @@ -78,7 +79,7 @@ static final class Deserializer extends StdDeserializer { } @java.lang.Override - public ViewerUser deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public ViewerUser deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/merge/api/resources/ticketing/users/AsyncRawUsersClient.java b/src/main/java/com/merge/api/resources/ticketing/users/AsyncRawUsersClient.java new file mode 100644 index 000000000..95bd657bb --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/users/AsyncRawUsersClient.java @@ -0,0 +1,245 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.users; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.PaginatedUserList; +import com.merge.api.resources.ticketing.types.User; +import com.merge.api.resources.ticketing.users.requests.UsersListRequest; +import com.merge.api.resources.ticketing.users.requests.UsersRetrieveRequest; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawUsersClient { + protected final ClientOptions clientOptions; + + public AsyncRawUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> list() { + return list(UsersListRequest.builder().build()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> list(UsersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture> list( + UsersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/users"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email_address", request.getEmailAddress().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTeam().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "team", request.getTeam().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture> retrieve(String id) { + return retrieve(id, UsersRetrieveRequest.builder().build()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture> retrieve(String id, UsersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture> retrieve( + String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/users") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), User.class), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/users/AsyncUsersClient.java b/src/main/java/com/merge/api/resources/ticketing/users/AsyncUsersClient.java new file mode 100644 index 000000000..09400049a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/users/AsyncUsersClient.java @@ -0,0 +1,72 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.users; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.PaginatedUserList; +import com.merge.api.resources.ticketing.types.User; +import com.merge.api.resources.ticketing.users.requests.UsersListRequest; +import com.merge.api.resources.ticketing.users.requests.UsersRetrieveRequest; +import java.util.concurrent.CompletableFuture; + +public class AsyncUsersClient { + protected final ClientOptions clientOptions; + + private final AsyncRawUsersClient rawClient; + + public AsyncUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawUsersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawUsersClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture list(UsersListRequest request) { + return this.rawClient.list(request).thenApply(response -> response.body()); + } + + /** + * Returns a list of User objects. + */ + public CompletableFuture list(UsersListRequest request, RequestOptions requestOptions) { + return this.rawClient.list(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture retrieve(String id) { + return this.rawClient.retrieve(id).thenApply(response -> response.body()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture retrieve(String id, UsersRetrieveRequest request) { + return this.rawClient.retrieve(id, request).thenApply(response -> response.body()); + } + + /** + * Returns a User object with the given id. + */ + public CompletableFuture retrieve(String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + return this.rawClient.retrieve(id, request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/users/RawUsersClient.java b/src/main/java/com/merge/api/resources/ticketing/users/RawUsersClient.java new file mode 100644 index 000000000..d00111a29 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/users/RawUsersClient.java @@ -0,0 +1,212 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.users; + +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.QueryStringMapper; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.PaginatedUserList; +import com.merge.api.resources.ticketing.types.User; +import com.merge.api.resources.ticketing.users.requests.UsersListRequest; +import com.merge.api.resources.ticketing.users.requests.UsersRetrieveRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawUsersClient { + protected final ClientOptions clientOptions; + + public RawUsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse list() { + return list(UsersListRequest.builder().build()); + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse list(UsersListRequest request) { + return list(request, null); + } + + /** + * Returns a list of User objects. + */ + public MergeApiHttpResponse list(UsersListRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/users"); + if (request.getCreatedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_after", request.getCreatedAfter().get().toString(), false); + } + if (request.getCreatedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "created_before", request.getCreatedBefore().get().toString(), false); + } + if (request.getCursor().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "cursor", request.getCursor().get(), false); + } + if (request.getEmailAddress().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "email_address", request.getEmailAddress().get(), false); + } + if (request.getIncludeDeletedData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_deleted_data", + request.getIncludeDeletedData().get().toString(), + false); + } + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getModifiedAfter().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "modified_after", request.getModifiedAfter().get().toString(), false); + } + if (request.getModifiedBefore().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "modified_before", + request.getModifiedBefore().get().toString(), + false); + } + if (request.getPageSize().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "page_size", request.getPageSize().get().toString(), false); + } + if (request.getRemoteId().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "remote_id", request.getRemoteId().get(), false); + } + if (request.getTeam().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "team", request.getTeam().get(), false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Returns a User object with the given id. + */ + public MergeApiHttpResponse retrieve(String id) { + return retrieve(id, UsersRetrieveRequest.builder().build()); + } + + /** + * Returns a User object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, UsersRetrieveRequest request) { + return retrieve(id, request, null); + } + + /** + * Returns a User object with the given id. + */ + public MergeApiHttpResponse retrieve(String id, UsersRetrieveRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/users") + .addPathSegment(id); + if (request.getIncludeRemoteData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_remote_data", + request.getIncludeRemoteData().get().toString(), + false); + } + if (request.getIncludeShellData().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, + "include_shell_data", + request.getIncludeShellData().get().toString(), + false); + } + if (request.getExpand().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "expand", request.getExpand().get().toString(), false); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json"); + Request okhttpRequest = _requestBuilder.build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), User.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/users/UsersClient.java b/src/main/java/com/merge/api/resources/ticketing/users/UsersClient.java index d17ab700f..3a4c0aa45 100644 --- a/src/main/java/com/merge/api/resources/ticketing/users/UsersClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/users/UsersClient.java @@ -3,173 +3,69 @@ */ package com.merge.api.resources.ticketing.users; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.types.PaginatedUserList; import com.merge.api.resources.ticketing.types.User; import com.merge.api.resources.ticketing.users.requests.UsersListRequest; import com.merge.api.resources.ticketing.users.requests.UsersRetrieveRequest; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; public class UsersClient { protected final ClientOptions clientOptions; + private final RawUsersClient rawClient; + public UsersClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawUsersClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawUsersClient withRawResponse() { + return this.rawClient; } /** * Returns a list of User objects. */ public PaginatedUserList list() { - return list(UsersListRequest.builder().build()); + return this.rawClient.list().body(); } /** * Returns a list of User objects. */ public PaginatedUserList list(UsersListRequest request) { - return list(request, null); + return this.rawClient.list(request).body(); } /** * Returns a list of User objects. */ public PaginatedUserList list(UsersListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/users"); - if (request.getCreatedAfter().isPresent()) { - httpUrl.addQueryParameter( - "created_after", request.getCreatedAfter().get().toString()); - } - if (request.getCreatedBefore().isPresent()) { - httpUrl.addQueryParameter( - "created_before", request.getCreatedBefore().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEmailAddress().isPresent()) { - httpUrl.addQueryParameter("email_address", request.getEmailAddress().get()); - } - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeDeletedData().isPresent()) { - httpUrl.addQueryParameter( - "include_deleted_data", - request.getIncludeDeletedData().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - if (request.getIncludeShellData().isPresent()) { - httpUrl.addQueryParameter( - "include_shell_data", request.getIncludeShellData().get().toString()); - } - if (request.getModifiedAfter().isPresent()) { - httpUrl.addQueryParameter( - "modified_after", request.getModifiedAfter().get().toString()); - } - if (request.getModifiedBefore().isPresent()) { - httpUrl.addQueryParameter( - "modified_before", request.getModifiedBefore().get().toString()); - } - if (request.getPageSize().isPresent()) { - httpUrl.addQueryParameter("page_size", request.getPageSize().get().toString()); - } - if (request.getRemoteId().isPresent()) { - httpUrl.addQueryParameter("remote_id", request.getRemoteId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), PaginatedUserList.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(request, requestOptions).body(); } /** * Returns a User object with the given id. */ public User retrieve(String id) { - return retrieve(id, UsersRetrieveRequest.builder().build()); + return this.rawClient.retrieve(id).body(); } /** * Returns a User object with the given id. */ public User retrieve(String id, UsersRetrieveRequest request) { - return retrieve(id, request, null); + return this.rawClient.retrieve(id, request).body(); } /** * Returns a User object with the given id. */ public User retrieve(String id, UsersRetrieveRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/users") - .addPathSegment(id); - if (request.getExpand().isPresent()) { - httpUrl.addQueryParameter("expand", request.getExpand().get().toString()); - } - if (request.getIncludeRemoteData().isPresent()) { - httpUrl.addQueryParameter( - "include_remote_data", request.getIncludeRemoteData().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), User.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.retrieve(id, request, requestOptions).body(); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/users/requests/UsersListRequest.java b/src/main/java/com/merge/api/resources/ticketing/users/requests/UsersListRequest.java index cc151fad4..69898b697 100644 --- a/src/main/java/com/merge/api/resources/ticketing/users/requests/UsersListRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/users/requests/UsersListRequest.java @@ -12,9 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ticketing.users.types.UsersListRequestExpand; +import com.merge.api.resources.ticketing.users.types.UsersListRequestExpandItem; import java.time.OffsetDateTime; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -22,6 +24,8 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UsersListRequest.Builder.class) public final class UsersListRequest { + private final Optional> expand; + private final Optional createdAfter; private final Optional createdBefore; @@ -30,8 +34,6 @@ public final class UsersListRequest { private final Optional emailAddress; - private final Optional expand; - private final Optional includeDeletedData; private final Optional includeRemoteData; @@ -46,14 +48,16 @@ public final class UsersListRequest { private final Optional remoteId; + private final Optional team; + private final Map additionalProperties; private UsersListRequest( + Optional> expand, Optional createdAfter, Optional createdBefore, Optional cursor, Optional emailAddress, - Optional expand, Optional includeDeletedData, Optional includeRemoteData, Optional includeShellData, @@ -61,12 +65,13 @@ private UsersListRequest( Optional modifiedBefore, Optional pageSize, Optional remoteId, + Optional team, Map additionalProperties) { + this.expand = expand; this.createdAfter = createdAfter; this.createdBefore = createdBefore; this.cursor = cursor; this.emailAddress = emailAddress; - this.expand = expand; this.includeDeletedData = includeDeletedData; this.includeRemoteData = includeRemoteData; this.includeShellData = includeShellData; @@ -74,9 +79,18 @@ private UsersListRequest( this.modifiedBefore = modifiedBefore; this.pageSize = pageSize; this.remoteId = remoteId; + this.team = team; this.additionalProperties = additionalProperties; } + /** + * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. + */ + @JsonProperty("expand") + public Optional> getExpand() { + return expand; + } + /** * @return If provided, will only return objects created after this datetime. */ @@ -109,14 +123,6 @@ public Optional getEmailAddress() { return emailAddress; } - /** - * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. - */ - @JsonProperty("expand") - public Optional getExpand() { - return expand; - } - /** * @return Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. Learn more. */ @@ -173,6 +179,14 @@ public Optional getRemoteId() { return remoteId; } + /** + * @return If provided, will only return users matching in this team. + */ + @JsonProperty("team") + public Optional getTeam() { + return team; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -185,35 +199,37 @@ public Map getAdditionalProperties() { } private boolean equalTo(UsersListRequest other) { - return createdAfter.equals(other.createdAfter) + return expand.equals(other.expand) + && createdAfter.equals(other.createdAfter) && createdBefore.equals(other.createdBefore) && cursor.equals(other.cursor) && emailAddress.equals(other.emailAddress) - && expand.equals(other.expand) && includeDeletedData.equals(other.includeDeletedData) && includeRemoteData.equals(other.includeRemoteData) && includeShellData.equals(other.includeShellData) && modifiedAfter.equals(other.modifiedAfter) && modifiedBefore.equals(other.modifiedBefore) && pageSize.equals(other.pageSize) - && remoteId.equals(other.remoteId); + && remoteId.equals(other.remoteId) + && team.equals(other.team); } @java.lang.Override public int hashCode() { return Objects.hash( + this.expand, this.createdAfter, this.createdBefore, this.cursor, this.emailAddress, - this.expand, this.includeDeletedData, this.includeRemoteData, this.includeShellData, this.modifiedAfter, this.modifiedBefore, this.pageSize, - this.remoteId); + this.remoteId, + this.team); } @java.lang.Override @@ -227,6 +243,8 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { + private Optional> expand = Optional.empty(); + private Optional createdAfter = Optional.empty(); private Optional createdBefore = Optional.empty(); @@ -235,8 +253,6 @@ public static final class Builder { private Optional emailAddress = Optional.empty(); - private Optional expand = Optional.empty(); - private Optional includeDeletedData = Optional.empty(); private Optional includeRemoteData = Optional.empty(); @@ -251,17 +267,19 @@ public static final class Builder { private Optional remoteId = Optional.empty(); + private Optional team = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} public Builder from(UsersListRequest other) { + expand(other.getExpand()); createdAfter(other.getCreatedAfter()); createdBefore(other.getCreatedBefore()); cursor(other.getCursor()); emailAddress(other.getEmailAddress()); - expand(other.getExpand()); includeDeletedData(other.getIncludeDeletedData()); includeRemoteData(other.getIncludeRemoteData()); includeShellData(other.getIncludeShellData()); @@ -269,6 +287,23 @@ public Builder from(UsersListRequest other) { modifiedBefore(other.getModifiedBefore()); pageSize(other.getPageSize()); remoteId(other.getRemoteId()); + team(other.getTeam()); + return this; + } + + @JsonSetter(value = "expand", nulls = Nulls.SKIP) + public Builder expand(Optional> expand) { + this.expand = expand; + return this; + } + + public Builder expand(List expand) { + this.expand = Optional.ofNullable(expand); + return this; + } + + public Builder expand(UsersListRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); return this; } @@ -316,17 +351,6 @@ public Builder emailAddress(String emailAddress) { return this; } - @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { - this.expand = expand; - return this; - } - - public Builder expand(UsersListRequestExpand expand) { - this.expand = Optional.ofNullable(expand); - return this; - } - @JsonSetter(value = "include_deleted_data", nulls = Nulls.SKIP) public Builder includeDeletedData(Optional includeDeletedData) { this.includeDeletedData = includeDeletedData; @@ -404,13 +428,24 @@ public Builder remoteId(String remoteId) { return this; } + @JsonSetter(value = "team", nulls = Nulls.SKIP) + public Builder team(Optional team) { + this.team = team; + return this; + } + + public Builder team(String team) { + this.team = Optional.ofNullable(team); + return this; + } + public UsersListRequest build() { return new UsersListRequest( + expand, createdAfter, createdBefore, cursor, emailAddress, - expand, includeDeletedData, includeRemoteData, includeShellData, @@ -418,6 +453,7 @@ public UsersListRequest build() { modifiedBefore, pageSize, remoteId, + team, additionalProperties); } } diff --git a/src/main/java/com/merge/api/resources/ticketing/users/requests/UsersRetrieveRequest.java b/src/main/java/com/merge/api/resources/ticketing/users/requests/UsersRetrieveRequest.java index 1d7296763..7880e6dd1 100644 --- a/src/main/java/com/merge/api/resources/ticketing/users/requests/UsersRetrieveRequest.java +++ b/src/main/java/com/merge/api/resources/ticketing/users/requests/UsersRetrieveRequest.java @@ -12,8 +12,10 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.merge.api.core.ObjectMappers; -import com.merge.api.resources.ticketing.users.types.UsersRetrieveRequestExpand; +import com.merge.api.resources.ticketing.users.types.UsersRetrieveRequestExpandItem; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -21,18 +23,22 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = UsersRetrieveRequest.Builder.class) public final class UsersRetrieveRequest { - private final Optional expand; + private final Optional> expand; private final Optional includeRemoteData; + private final Optional includeShellData; + private final Map additionalProperties; private UsersRetrieveRequest( - Optional expand, + Optional> expand, Optional includeRemoteData, + Optional includeShellData, Map additionalProperties) { this.expand = expand; this.includeRemoteData = includeRemoteData; + this.includeShellData = includeShellData; this.additionalProperties = additionalProperties; } @@ -40,7 +46,7 @@ private UsersRetrieveRequest( * @return Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces. */ @JsonProperty("expand") - public Optional getExpand() { + public Optional> getExpand() { return expand; } @@ -52,6 +58,14 @@ public Optional getIncludeRemoteData() { return includeRemoteData; } + /** + * @return Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null). + */ + @JsonProperty("include_shell_data") + public Optional getIncludeShellData() { + return includeShellData; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -64,12 +78,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(UsersRetrieveRequest other) { - return expand.equals(other.expand) && includeRemoteData.equals(other.includeRemoteData); + return expand.equals(other.expand) + && includeRemoteData.equals(other.includeRemoteData) + && includeShellData.equals(other.includeShellData); } @java.lang.Override public int hashCode() { - return Objects.hash(this.expand, this.includeRemoteData); + return Objects.hash(this.expand, this.includeRemoteData, this.includeShellData); } @java.lang.Override @@ -83,10 +99,12 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional expand = Optional.empty(); + private Optional> expand = Optional.empty(); private Optional includeRemoteData = Optional.empty(); + private Optional includeShellData = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -95,20 +113,26 @@ private Builder() {} public Builder from(UsersRetrieveRequest other) { expand(other.getExpand()); includeRemoteData(other.getIncludeRemoteData()); + includeShellData(other.getIncludeShellData()); return this; } @JsonSetter(value = "expand", nulls = Nulls.SKIP) - public Builder expand(Optional expand) { + public Builder expand(Optional> expand) { this.expand = expand; return this; } - public Builder expand(UsersRetrieveRequestExpand expand) { + public Builder expand(List expand) { this.expand = Optional.ofNullable(expand); return this; } + public Builder expand(UsersRetrieveRequestExpandItem expand) { + this.expand = Optional.of(Collections.singletonList(expand)); + return this; + } + @JsonSetter(value = "include_remote_data", nulls = Nulls.SKIP) public Builder includeRemoteData(Optional includeRemoteData) { this.includeRemoteData = includeRemoteData; @@ -120,8 +144,19 @@ public Builder includeRemoteData(Boolean includeRemoteData) { return this; } + @JsonSetter(value = "include_shell_data", nulls = Nulls.SKIP) + public Builder includeShellData(Optional includeShellData) { + this.includeShellData = includeShellData; + return this; + } + + public Builder includeShellData(Boolean includeShellData) { + this.includeShellData = Optional.ofNullable(includeShellData); + return this; + } + public UsersRetrieveRequest build() { - return new UsersRetrieveRequest(expand, includeRemoteData, additionalProperties); + return new UsersRetrieveRequest(expand, includeRemoteData, includeShellData, additionalProperties); } } } diff --git a/src/main/java/com/merge/api/resources/ticketing/users/types/UsersListRequestExpand.java b/src/main/java/com/merge/api/resources/ticketing/users/types/UsersListRequestExpand.java deleted file mode 100644 index d4ee2c067..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/users/types/UsersListRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.users.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum UsersListRequestExpand { - ROLES("roles"), - - TEAMS("teams"), - - TEAMS_ROLES("teams,roles"); - - private final String value; - - UsersListRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/users/types/UsersListRequestExpandItem.java b/src/main/java/com/merge/api/resources/ticketing/users/types/UsersListRequestExpandItem.java new file mode 100644 index 000000000..f7bd3f103 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/users/types/UsersListRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.users.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum UsersListRequestExpandItem { + ROLES("roles"), + + TEAMS("teams"); + + private final String value; + + UsersListRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/users/types/UsersRetrieveRequestExpand.java b/src/main/java/com/merge/api/resources/ticketing/users/types/UsersRetrieveRequestExpand.java deleted file mode 100644 index b3450de03..000000000 --- a/src/main/java/com/merge/api/resources/ticketing/users/types/UsersRetrieveRequestExpand.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.merge.api.resources.ticketing.users.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum UsersRetrieveRequestExpand { - ROLES("roles"), - - TEAMS("teams"), - - TEAMS_ROLES("teams,roles"); - - private final String value; - - UsersRetrieveRequestExpand(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/merge/api/resources/ticketing/users/types/UsersRetrieveRequestExpandItem.java b/src/main/java/com/merge/api/resources/ticketing/users/types/UsersRetrieveRequestExpandItem.java new file mode 100644 index 000000000..4f1d740b5 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/users/types/UsersRetrieveRequestExpandItem.java @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.users.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum UsersRetrieveRequestExpandItem { + ROLES("roles"), + + TEAMS("teams"); + + private final String value; + + UsersRetrieveRequestExpandItem(String value) { + this.value = value; + } + + @JsonValue + @java.lang.Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/AsyncRawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/AsyncRawWebhookReceiversClient.java new file mode 100644 index 000000000..80b2249e4 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/AsyncRawWebhookReceiversClient.java @@ -0,0 +1,160 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.WebhookReceiver; +import com.merge.api.resources.ticketing.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public AsyncRawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture>> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture>> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture> create( + WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + if (response.isSuccessful()) { + future.complete(new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), + response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response)); + return; + } catch (IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new MergeException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/AsyncWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/AsyncWebhookReceiversClient.java new file mode 100644 index 000000000..0ddf6778a --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/AsyncWebhookReceiversClient.java @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.webhookreceivers; + +import com.merge.api.core.ClientOptions; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.WebhookReceiver; +import com.merge.api.resources.ticketing.webhookreceivers.requests.WebhookReceiverRequest; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class AsyncWebhookReceiversClient { + protected final ClientOptions clientOptions; + + private final AsyncRawWebhookReceiversClient rawClient; + + public AsyncWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawWebhookReceiversClient withRawResponse() { + return this.rawClient; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list() { + return this.rawClient.list().thenApply(response -> response.body()); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public CompletableFuture> list(RequestOptions requestOptions) { + return this.rawClient.list(requestOptions).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request) { + return this.rawClient.create(request).thenApply(response -> response.body()); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public CompletableFuture create(WebhookReceiverRequest request, RequestOptions requestOptions) { + return this.rawClient.create(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/RawWebhookReceiversClient.java b/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/RawWebhookReceiversClient.java new file mode 100644 index 000000000..dcff94f05 --- /dev/null +++ b/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/RawWebhookReceiversClient.java @@ -0,0 +1,128 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.resources.ticketing.webhookreceivers; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.merge.api.core.ApiError; +import com.merge.api.core.ClientOptions; +import com.merge.api.core.MediaTypes; +import com.merge.api.core.MergeApiHttpResponse; +import com.merge.api.core.MergeException; +import com.merge.api.core.ObjectMappers; +import com.merge.api.core.RequestOptions; +import com.merge.api.resources.ticketing.types.WebhookReceiver; +import com.merge.api.resources.ticketing.webhookreceivers.requests.WebhookReceiverRequest; +import java.io.IOException; +import java.util.List; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawWebhookReceiversClient { + protected final ClientOptions clientOptions; + + public RawWebhookReceiversClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list() { + return list(null); + } + + /** + * Returns a list of WebhookReceiver objects. + */ + public MergeApiHttpResponse> list(RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/webhook-receivers") + .build(); + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBody.string(), new TypeReference>() {}), + response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request) { + return create(request, null); + } + + /** + * Creates a WebhookReceiver object with the given values. + */ + public MergeApiHttpResponse create(WebhookReceiverRequest request, RequestOptions requestOptions) { + HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("ticketing/v1/webhook-receivers") + .build(); + RequestBody body; + try { + body = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); + } catch (JsonProcessingException e) { + throw new MergeException("Failed to serialize request", e); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl) + .method("POST", body) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new MergeApiHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + throw new ApiError( + "Error with status code " + response.code(), + response.code(), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), + response); + } catch (IOException e) { + throw new MergeException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/WebhookReceiversClient.java b/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/WebhookReceiversClient.java index 875ae6e08..bd76ed535 100644 --- a/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/WebhookReceiversClient.java +++ b/src/main/java/com/merge/api/resources/ticketing/webhookreceivers/WebhookReceiversClient.java @@ -3,120 +3,54 @@ */ package com.merge.api.resources.ticketing.webhookreceivers; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.merge.api.core.ApiError; import com.merge.api.core.ClientOptions; -import com.merge.api.core.MediaTypes; -import com.merge.api.core.MergeException; -import com.merge.api.core.ObjectMappers; import com.merge.api.core.RequestOptions; import com.merge.api.resources.ticketing.types.WebhookReceiver; import com.merge.api.resources.ticketing.webhookreceivers.requests.WebhookReceiverRequest; -import java.io.IOException; import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; public class WebhookReceiversClient { protected final ClientOptions clientOptions; + private final RawWebhookReceiversClient rawClient; + public WebhookReceiversClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; + this.rawClient = new RawWebhookReceiversClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawWebhookReceiversClient withRawResponse() { + return this.rawClient; } /** * Returns a list of WebhookReceiver objects. */ public List list() { - return list(null); + return this.rawClient.list().body(); } /** * Returns a list of WebhookReceiver objects. */ public List list(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/webhook-receivers") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.list(requestOptions).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request) { - return create(request, null); + return this.rawClient.create(request).body(); } /** * Creates a WebhookReceiver object with the given values. */ public WebhookReceiver create(WebhookReceiverRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("ticketing/v1/webhook-receivers") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new MergeException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), WebhookReceiver.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new ApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new MergeException("Network error executing HTTP request", e); - } + return this.rawClient.create(request, requestOptions).body(); } } diff --git a/src/test/java/com/merge/api/core/QueryStringMapperTest.java b/src/test/java/com/merge/api/core/QueryStringMapperTest.java new file mode 100644 index 000000000..15fe80b35 --- /dev/null +++ b/src/test/java/com/merge/api/core/QueryStringMapperTest.java @@ -0,0 +1,339 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.merge.api.core; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.HttpUrl; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public final class QueryStringMapperTest { + @Test + public void testObjectWithQuotedString_indexedArrays() { + Map map = new HashMap() { + { + put("hello", "\"world\""); + } + }; + + String expectedQueryString = "withquoted%5Bhello%5D=%22world%22"; + + String actualQueryString = queryString( + new HashMap() { + { + put("withquoted", map); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObjectWithQuotedString_arraysAsRepeats() { + Map map = new HashMap() { + { + put("hello", "\"world\""); + } + }; + + String expectedQueryString = "withquoted%5Bhello%5D=%22world%22"; + + String actualQueryString = queryString( + new HashMap() { + { + put("withquoted", map); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObject_indexedArrays() { + Map map = new HashMap() { + { + put("foo", "bar"); + put("baz", "qux"); + } + }; + + String expectedQueryString = "metadata%5Bfoo%5D=bar&metadata%5Bbaz%5D=qux"; + + String actualQueryString = queryString( + new HashMap() { + { + put("metadata", map); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObject_arraysAsRepeats() { + Map map = new HashMap() { + { + put("foo", "bar"); + put("baz", "qux"); + } + }; + + String expectedQueryString = "metadata%5Bfoo%5D=bar&metadata%5Bbaz%5D=qux"; + + String actualQueryString = queryString( + new HashMap() { + { + put("metadata", map); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testNestedObject_indexedArrays() { + Map> nestedMap = new HashMap>() { + { + put("mapkey1", new HashMap() { + { + put("mapkey1mapkey1", "mapkey1mapkey1value"); + put("mapkey1mapkey2", "mapkey1mapkey2value"); + } + }); + put("mapkey2", new HashMap() { + { + put("mapkey2mapkey1", "mapkey2mapkey1value"); + } + }); + } + }; + + String expectedQueryString = + "nested%5Bmapkey2%5D%5Bmapkey2mapkey1%5D=mapkey2mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey1" + + "%5D=mapkey1mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey2%5D=mapkey1mapkey2value"; + + String actualQueryString = queryString( + new HashMap() { + { + put("nested", nestedMap); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testNestedObject_arraysAsRepeats() { + Map> nestedMap = new HashMap>() { + { + put("mapkey1", new HashMap() { + { + put("mapkey1mapkey1", "mapkey1mapkey1value"); + put("mapkey1mapkey2", "mapkey1mapkey2value"); + } + }); + put("mapkey2", new HashMap() { + { + put("mapkey2mapkey1", "mapkey2mapkey1value"); + } + }); + } + }; + + String expectedQueryString = + "nested%5Bmapkey2%5D%5Bmapkey2mapkey1%5D=mapkey2mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey1" + + "%5D=mapkey1mapkey1value&nested%5Bmapkey1%5D%5Bmapkey1mapkey2%5D=mapkey1mapkey2value"; + + String actualQueryString = queryString( + new HashMap() { + { + put("nested", nestedMap); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testDateTime_indexedArrays() { + OffsetDateTime dateTime = + OffsetDateTime.ofInstant(Instant.ofEpochSecond(1740412107L), ZoneId.of("America/New_York")); + + String expectedQueryString = "datetime=2025-02-24T10%3A48%3A27-05%3A00"; + + String actualQueryString = queryString( + new HashMap() { + { + put("datetime", dateTime); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testDateTime_arraysAsRepeats() { + OffsetDateTime dateTime = + OffsetDateTime.ofInstant(Instant.ofEpochSecond(1740412107L), ZoneId.of("America/New_York")); + + String expectedQueryString = "datetime=2025-02-24T10%3A48%3A27-05%3A00"; + + String actualQueryString = queryString( + new HashMap() { + { + put("datetime", dateTime); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObjectArray_indexedArrays() { + List> mapArray = new ArrayList>() { + { + add(new HashMap() { + { + put("key", "hello"); + put("value", "world"); + } + }); + add(new HashMap() { + { + put("key", "foo"); + put("value", "bar"); + } + }); + add(new HashMap<>()); + } + }; + + String expectedQueryString = "objects%5B0%5D%5Bvalue%5D=world&objects%5B0%5D%5Bkey%5D=hello&objects%5B1%5D" + + "%5Bvalue%5D=bar&objects%5B1%5D%5Bkey%5D=foo"; + + String actualQueryString = queryString( + new HashMap() { + { + put("objects", mapArray); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObjectArray_arraysAsRepeats() { + List> mapArray = new ArrayList>() { + { + add(new HashMap() { + { + put("key", "hello"); + put("value", "world"); + } + }); + add(new HashMap() { + { + put("key", "foo"); + put("value", "bar"); + } + }); + add(new HashMap<>()); + } + }; + + String expectedQueryString = + "objects%5Bvalue%5D=world&objects%5Bkey%5D=hello&objects%5Bvalue" + "%5D=bar&objects%5Bkey%5D=foo"; + + String actualQueryString = queryString( + new HashMap() { + { + put("objects", mapArray); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObjectWithArray_indexedArrays() { + Map objectWithArray = new HashMap() { + { + put("id", "abc123"); + put("contactIds", new ArrayList() { + { + add("id1"); + add("id2"); + add("id3"); + } + }); + } + }; + + String expectedQueryString = + "objectwitharray%5Bid%5D=abc123&objectwitharray%5BcontactIds%5D%5B0%5D=id1&objectwitharray" + + "%5BcontactIds%5D%5B1%5D=id2&objectwitharray%5BcontactIds%5D%5B2%5D=id3"; + + String actualQueryString = queryString( + new HashMap() { + { + put("objectwitharray", objectWithArray); + } + }, + false); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + @Test + public void testObjectWithArray_arraysAsRepeats() { + Map objectWithArray = new HashMap() { + { + put("id", "abc123"); + put("contactIds", new ArrayList() { + { + add("id1"); + add("id2"); + add("id3"); + } + }); + } + }; + + String expectedQueryString = "objectwitharray%5Bid%5D=abc123&objectwitharray%5BcontactIds" + + "%5D=id1&objectwitharray%5BcontactIds%5D=id2&objectwitharray%5BcontactIds%5D=id3"; + + String actualQueryString = queryString( + new HashMap() { + { + put("objectwitharray", objectWithArray); + } + }, + true); + + Assertions.assertEquals(expectedQueryString, actualQueryString); + } + + private static String queryString(Map params, boolean arraysAsRepeats) { + HttpUrl.Builder httpUrl = HttpUrl.parse("http://www.fakewebsite.com/").newBuilder(); + params.forEach((paramName, paramValue) -> + QueryStringMapper.addQueryParameter(httpUrl, paramName, paramValue, arraysAsRepeats)); + return httpUrl.build().encodedQuery(); + } +}