Skip to content

Commit 19015fa

Browse files
Sync SDK with updates to Merge API, fix PermissionRequest object typing, RequestOptions added (#35)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 5b36da3 commit 19015fa

File tree

1,851 files changed

+39908
-7884
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,851 files changed

+39908
-7884
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ publishing {
4646
maven(MavenPublication) {
4747
groupId = 'dev.merge'
4848
artifactId = 'merge-java-client'
49-
version = '1.0.5'
49+
version = '1.0.6'
5050
from components.java
5151
}
5252
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew.bat

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
4343
%JAVA_EXE% -version >NUL 2>&1
4444
if %ERRORLEVEL% equ 0 goto execute
4545

46-
echo.
47-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48-
echo.
49-
echo Please set the JAVA_HOME variable in your environment to match the
50-
echo location of your Java installation.
46+
echo. 1>&2
47+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48+
echo. 1>&2
49+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50+
echo location of your Java installation. 1>&2
5151

5252
goto fail
5353

@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5757

5858
if exist "%JAVA_EXE%" goto execute
5959

60-
echo.
61-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62-
echo.
63-
echo Please set the JAVA_HOME variable in your environment to match the
64-
echo location of your Java installation.
60+
echo. 1>&2
61+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62+
echo. 1>&2
63+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64+
echo location of your Java installation. 1>&2
6565

6666
goto fail
6767

src/main/java/com/merge/api/MergeApiClientBuilder.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,25 @@
99
public final class MergeApiClientBuilder {
1010
private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder();
1111

12+
private String apiKey = null;
13+
14+
private String accountToken = null;
15+
1216
private Environment environment = Environment.PRODUCTION;
1317

18+
/**
19+
* Sets apiKey
20+
*/
1421
public MergeApiClientBuilder apiKey(String apiKey) {
15-
this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + apiKey);
22+
this.apiKey = apiKey;
1623
return this;
1724
}
1825

26+
/**
27+
* Sets accountToken
28+
*/
1929
public MergeApiClientBuilder accountToken(String accountToken) {
20-
this.clientOptionsBuilder.addHeader("X-Account-Token", accountToken);
30+
this.accountToken = accountToken;
2131
return this;
2232
}
2333

@@ -32,6 +42,14 @@ public MergeApiClientBuilder url(String url) {
3242
}
3343

3444
public MergeApiClient build() {
45+
if (apiKey == null) {
46+
throw new RuntimeException("Please provide apiKey");
47+
}
48+
this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.apiKey);
49+
if (accountToken == null) {
50+
throw new RuntimeException("Please provide accountToken");
51+
}
52+
this.clientOptionsBuilder.addHeader("X-Account-Token", this.accountToken);
3553
clientOptionsBuilder.environment(this.environment);
3654
return new MergeApiClient(clientOptionsBuilder.build());
3755
}

src/main/java/com/merge/api/core/ApiError.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public Object body() {
2121
return this.body;
2222
}
2323

24-
@Override
24+
@java.lang.Override
2525
public String toString() {
2626
return "ApiError{" + "statusCode: " + statusCode + ", body: " + body + "}";
2727
}

src/main/java/com/merge/api/core/ClientOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private ClientOptions(
2626
this.headers = new HashMap<>();
2727
this.headers.putAll(headers);
2828
this.headers.putAll(Map.of(
29-
"X-Fern-SDK-Name", "com.merge.fern:api-sdk", "X-Fern-SDK-Version", "1.0.5", "X-Fern-Language", "JAVA"));
29+
"X-Fern-SDK-Name", "com.merge.fern:api-sdk", "X-Fern-SDK-Version", "1.0.6", "X-Fern-Language", "JAVA"));
3030
this.headerSuppliers = headerSuppliers;
3131
this.httpClient = httpClient;
3232
;

src/main/java/com/merge/api/core/RequestOptions.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,31 @@
55

66
import java.util.HashMap;
77
import java.util.Map;
8+
import java.util.Optional;
9+
import java.util.concurrent.TimeUnit;
810

911
public final class RequestOptions {
1012
private final String apiKey;
1113

1214
private final String accountToken;
1315

14-
private RequestOptions(String apiKey, String accountToken) {
16+
private final Optional<Integer> timeout;
17+
18+
private final TimeUnit timeoutTimeUnit;
19+
20+
private RequestOptions(String apiKey, String accountToken, Optional<Integer> timeout, TimeUnit timeoutTimeUnit) {
1521
this.apiKey = apiKey;
1622
this.accountToken = accountToken;
23+
this.timeout = timeout;
24+
this.timeoutTimeUnit = timeoutTimeUnit;
25+
}
26+
27+
public Optional<Integer> getTimeout() {
28+
return timeout;
29+
}
30+
31+
public TimeUnit getTimeoutTimeUnit() {
32+
return timeoutTimeUnit;
1733
}
1834

1935
public Map<String, String> getHeaders() {
@@ -36,6 +52,10 @@ public static final class Builder {
3652

3753
private String accountToken = null;
3854

55+
private Optional<Integer> timeout = null;
56+
57+
private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS;
58+
3959
public Builder apiKey(String apiKey) {
4060
this.apiKey = apiKey;
4161
return this;
@@ -46,8 +66,19 @@ public Builder accountToken(String accountToken) {
4666
return this;
4767
}
4868

69+
public Builder timeout(Integer timeout) {
70+
this.timeout = Optional.of(timeout);
71+
return this;
72+
}
73+
74+
public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) {
75+
this.timeout = Optional.of(timeout);
76+
this.timeoutTimeUnit = timeoutTimeUnit;
77+
return this;
78+
}
79+
4980
public RequestOptions build() {
50-
return new RequestOptions(apiKey, accountToken);
81+
return new RequestOptions(apiKey, accountToken, timeout, timeoutTimeUnit);
5182
}
5283
}
5384
}

src/main/java/com/merge/api/resources/accounting/AccountingClient.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.merge.api.resources.accounting.creditnotes.CreditNotesClient;
2222
import com.merge.api.resources.accounting.deleteaccount.DeleteAccountClient;
2323
import com.merge.api.resources.accounting.expenses.ExpensesClient;
24+
import com.merge.api.resources.accounting.fieldmapping.FieldMappingClient;
2425
import com.merge.api.resources.accounting.forceresync.ForceResyncClient;
2526
import com.merge.api.resources.accounting.generatekey.GenerateKeyClient;
2627
import com.merge.api.resources.accounting.incomestatements.IncomeStatementsClient;
@@ -35,6 +36,7 @@
3536
import com.merge.api.resources.accounting.phonenumbers.PhoneNumbersClient;
3637
import com.merge.api.resources.accounting.purchaseorders.PurchaseOrdersClient;
3738
import com.merge.api.resources.accounting.regeneratekey.RegenerateKeyClient;
39+
import com.merge.api.resources.accounting.scopes.ScopesClient;
3840
import com.merge.api.resources.accounting.selectivesync.SelectiveSyncClient;
3941
import com.merge.api.resources.accounting.syncstatus.SyncStatusClient;
4042
import com.merge.api.resources.accounting.taxrates.TaxRatesClient;
@@ -75,10 +77,14 @@ public class AccountingClient {
7577

7678
protected final Supplier<CreditNotesClient> creditNotesClient;
7779

80+
protected final Supplier<ScopesClient> scopesClient;
81+
7882
protected final Supplier<DeleteAccountClient> deleteAccountClient;
7983

8084
protected final Supplier<ExpensesClient> expensesClient;
8185

86+
protected final Supplier<FieldMappingClient> fieldMappingClient;
87+
8288
protected final Supplier<GenerateKeyClient> generateKeyClient;
8389

8490
protected final Supplier<IncomeStatementsClient> incomeStatementsClient;
@@ -137,8 +143,10 @@ public AccountingClient(ClientOptions clientOptions) {
137143
this.companyInfoClient = Suppliers.memoize(() -> new CompanyInfoClient(clientOptions));
138144
this.contactsClient = Suppliers.memoize(() -> new ContactsClient(clientOptions));
139145
this.creditNotesClient = Suppliers.memoize(() -> new CreditNotesClient(clientOptions));
146+
this.scopesClient = Suppliers.memoize(() -> new ScopesClient(clientOptions));
140147
this.deleteAccountClient = Suppliers.memoize(() -> new DeleteAccountClient(clientOptions));
141148
this.expensesClient = Suppliers.memoize(() -> new ExpensesClient(clientOptions));
149+
this.fieldMappingClient = Suppliers.memoize(() -> new FieldMappingClient(clientOptions));
142150
this.generateKeyClient = Suppliers.memoize(() -> new GenerateKeyClient(clientOptions));
143151
this.incomeStatementsClient = Suppliers.memoize(() -> new IncomeStatementsClient(clientOptions));
144152
this.invoicesClient = Suppliers.memoize(() -> new InvoicesClient(clientOptions));
@@ -218,6 +226,10 @@ public CreditNotesClient creditNotes() {
218226
return this.creditNotesClient.get();
219227
}
220228

229+
public ScopesClient scopes() {
230+
return this.scopesClient.get();
231+
}
232+
221233
public DeleteAccountClient deleteAccount() {
222234
return this.deleteAccountClient.get();
223235
}
@@ -226,6 +238,10 @@ public ExpensesClient expenses() {
226238
return this.expensesClient.get();
227239
}
228240

241+
public FieldMappingClient fieldMapping() {
242+
return this.fieldMappingClient.get();
243+
}
244+
229245
public GenerateKeyClient generateKey() {
230246
return this.generateKeyClient.get();
231247
}

src/main/java/com/merge/api/resources/accounting/accountdetails/AccountDetailsClient.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.io.IOException;
1212
import okhttp3.Headers;
1313
import okhttp3.HttpUrl;
14+
import okhttp3.OkHttpClient;
1415
import okhttp3.Request;
1516
import okhttp3.Response;
1617

@@ -43,8 +44,13 @@ public AccountDetails retrieve(RequestOptions requestOptions) {
4344
.addHeader("Content-Type", "application/json")
4445
.build();
4546
try {
46-
Response response =
47-
clientOptions.httpClient().newCall(okhttpRequest).execute();
47+
OkHttpClient client = clientOptions.httpClient();
48+
if (requestOptions.getTimeout().isPresent()) {
49+
client = client.newBuilder()
50+
.readTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit())
51+
.build();
52+
}
53+
Response response = client.newCall(okhttpRequest).execute();
4854
if (response.isSuccessful()) {
4955
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), AccountDetails.class);
5056
}

src/main/java/com/merge/api/resources/accounting/accountingperiods/AccountingPeriodsClient.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.io.IOException;
1515
import okhttp3.Headers;
1616
import okhttp3.HttpUrl;
17+
import okhttp3.OkHttpClient;
1718
import okhttp3.Request;
1819
import okhttp3.Response;
1920

@@ -67,8 +68,13 @@ public PaginatedAccountingPeriodList list(AccountingPeriodsListRequest request,
6768
.addHeader("Content-Type", "application/json");
6869
Request okhttpRequest = _requestBuilder.build();
6970
try {
70-
Response response =
71-
clientOptions.httpClient().newCall(okhttpRequest).execute();
71+
OkHttpClient client = clientOptions.httpClient();
72+
if (requestOptions.getTimeout().isPresent()) {
73+
client = client.newBuilder()
74+
.readTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit())
75+
.build();
76+
}
77+
Response response = client.newCall(okhttpRequest).execute();
7278
if (response.isSuccessful()) {
7379
return ObjectMappers.JSON_MAPPER.readValue(
7480
response.body().string(), PaginatedAccountingPeriodList.class);
@@ -115,8 +121,13 @@ public AccountingPeriod retrieve(
115121
.addHeader("Content-Type", "application/json");
116122
Request okhttpRequest = _requestBuilder.build();
117123
try {
118-
Response response =
119-
clientOptions.httpClient().newCall(okhttpRequest).execute();
124+
OkHttpClient client = clientOptions.httpClient();
125+
if (requestOptions.getTimeout().isPresent()) {
126+
client = client.newBuilder()
127+
.readTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit())
128+
.build();
129+
}
130+
Response response = client.newCall(okhttpRequest).execute();
120131
if (response.isSuccessful()) {
121132
return ObjectMappers.JSON_MAPPER.readValue(response.body().string(), AccountingPeriod.class);
122133
}

0 commit comments

Comments
 (0)