Skip to content

Commit 6b28d04

Browse files
Bump Payment Line items update (#24)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 968af1b commit 6b28d04

26 files changed

+2503
-2
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ publishing {
4040
maven(MavenPublication) {
4141
groupId = 'dev.merge'
4242
artifactId = 'merge-java-client'
43-
version = '0.1.7'
43+
version = '1.0.0'
4444
from components.java
4545
}
4646
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private ClientOptions(
2323
this.headers = new HashMap<>();
2424
this.headers.putAll(headers);
2525
this.headers.putAll(Map.of(
26-
"X-Fern-SDK-Name", "com.merge.fern:api-sdk", "X-Fern-SDK-Version", "0.1.7", "X-Fern-Language", "JAVA"));
26+
"X-Fern-SDK-Name", "com.merge.fern:api-sdk", "X-Fern-SDK-Version", "1.0.0", "X-Fern-Language", "JAVA"));
2727
this.headerSuppliers = headerSuppliers;
2828
this.httpClient = httpClient;
2929
;

src/main/java/com/merge/api/resources/accounting/types/CreditNote.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public final class CreditNote {
4949

5050
private final Optional<List<Optional<CreditNotePaymentsItem>>> payments;
5151

52+
private final Optional<List<Optional<CreditNoteAppliedPaymentsItem>>> appliedPayments;
53+
5254
private final Optional<Boolean> remoteWasDeleted;
5355

5456
private final Optional<CreditNoteAccountingPeriod> accountingPeriod;
@@ -78,6 +80,7 @@ private CreditNote(
7880
Optional<OffsetDateTime> remoteCreatedAt,
7981
Optional<OffsetDateTime> remoteUpdatedAt,
8082
Optional<List<Optional<CreditNotePaymentsItem>>> payments,
83+
Optional<List<Optional<CreditNoteAppliedPaymentsItem>>> appliedPayments,
8184
Optional<Boolean> remoteWasDeleted,
8285
Optional<CreditNoteAccountingPeriod> accountingPeriod,
8386
Optional<OffsetDateTime> createdAt,
@@ -100,6 +103,7 @@ private CreditNote(
100103
this.remoteCreatedAt = remoteCreatedAt;
101104
this.remoteUpdatedAt = remoteUpdatedAt;
102105
this.payments = payments;
106+
this.appliedPayments = appliedPayments;
103107
this.remoteWasDeleted = remoteWasDeleted;
104108
this.accountingPeriod = accountingPeriod;
105109
this.createdAt = createdAt;
@@ -540,6 +544,14 @@ public Optional<List<Optional<CreditNotePaymentsItem>>> getPayments() {
540544
return payments;
541545
}
542546

547+
/**
548+
* @return Array of <code>PaymentLineItems</code> object IDs.
549+
*/
550+
@JsonProperty("applied_payments")
551+
public Optional<List<Optional<CreditNoteAppliedPaymentsItem>>> getAppliedPayments() {
552+
return appliedPayments;
553+
}
554+
543555
/**
544556
* @return Indicates whether or not this object has been deleted in the third party platform.
545557
*/
@@ -602,6 +614,7 @@ private boolean equalTo(CreditNote other) {
602614
&& remoteCreatedAt.equals(other.remoteCreatedAt)
603615
&& remoteUpdatedAt.equals(other.remoteUpdatedAt)
604616
&& payments.equals(other.payments)
617+
&& appliedPayments.equals(other.appliedPayments)
605618
&& remoteWasDeleted.equals(other.remoteWasDeleted)
606619
&& accountingPeriod.equals(other.accountingPeriod)
607620
&& createdAt.equals(other.createdAt)
@@ -629,6 +642,7 @@ public int hashCode() {
629642
this.remoteCreatedAt,
630643
this.remoteUpdatedAt,
631644
this.payments,
645+
this.appliedPayments,
632646
this.remoteWasDeleted,
633647
this.accountingPeriod,
634648
this.createdAt,
@@ -680,6 +694,8 @@ public static final class Builder {
680694

681695
private Optional<List<Optional<CreditNotePaymentsItem>>> payments = Optional.empty();
682696

697+
private Optional<List<Optional<CreditNoteAppliedPaymentsItem>>> appliedPayments = Optional.empty();
698+
683699
private Optional<Boolean> remoteWasDeleted = Optional.empty();
684700

685701
private Optional<CreditNoteAccountingPeriod> accountingPeriod = Optional.empty();
@@ -711,6 +727,7 @@ public Builder from(CreditNote other) {
711727
remoteCreatedAt(other.getRemoteCreatedAt());
712728
remoteUpdatedAt(other.getRemoteUpdatedAt());
713729
payments(other.getPayments());
730+
appliedPayments(other.getAppliedPayments());
714731
remoteWasDeleted(other.getRemoteWasDeleted());
715732
accountingPeriod(other.getAccountingPeriod());
716733
createdAt(other.getCreatedAt());
@@ -897,6 +914,17 @@ public Builder payments(List<Optional<CreditNotePaymentsItem>> payments) {
897914
return this;
898915
}
899916

917+
@JsonSetter(value = "applied_payments", nulls = Nulls.SKIP)
918+
public Builder appliedPayments(Optional<List<Optional<CreditNoteAppliedPaymentsItem>>> appliedPayments) {
919+
this.appliedPayments = appliedPayments;
920+
return this;
921+
}
922+
923+
public Builder appliedPayments(List<Optional<CreditNoteAppliedPaymentsItem>> appliedPayments) {
924+
this.appliedPayments = Optional.of(appliedPayments);
925+
return this;
926+
}
927+
900928
@JsonSetter(value = "remote_was_deleted", nulls = Nulls.SKIP)
901929
public Builder remoteWasDeleted(Optional<Boolean> remoteWasDeleted) {
902930
this.remoteWasDeleted = remoteWasDeleted;
@@ -981,6 +1009,7 @@ public CreditNote build() {
9811009
remoteCreatedAt,
9821010
remoteUpdatedAt,
9831011
payments,
1012+
appliedPayments,
9841013
remoteWasDeleted,
9851014
accountingPeriod,
9861015
createdAt,
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package com.merge.api.resources.accounting.types;
2+
3+
import com.fasterxml.jackson.annotation.JsonValue;
4+
import com.fasterxml.jackson.core.JsonParseException;
5+
import com.fasterxml.jackson.core.JsonParser;
6+
import com.fasterxml.jackson.databind.DeserializationContext;
7+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
8+
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
9+
import com.merge.api.core.ObjectMappers;
10+
import java.io.IOException;
11+
import java.util.Objects;
12+
13+
@JsonDeserialize(using = CreditNoteAppliedPaymentsItem.Deserializer.class)
14+
public final class CreditNoteAppliedPaymentsItem {
15+
private final Object value;
16+
17+
private final int type;
18+
19+
private CreditNoteAppliedPaymentsItem(Object value, int type) {
20+
this.value = value;
21+
this.type = type;
22+
}
23+
24+
@JsonValue
25+
public Object get() {
26+
return this.value;
27+
}
28+
29+
public <T> T visit(Visitor<T> visitor) {
30+
if (this.type == 0) {
31+
return visitor.visit((String) this.value);
32+
} else if (this.type == 1) {
33+
return visitor.visit((PaymentLineItem) this.value);
34+
}
35+
throw new IllegalStateException("Failed to visit value. This should never happen.");
36+
}
37+
38+
@Override
39+
public boolean equals(Object other) {
40+
if (this == other) return true;
41+
return other instanceof CreditNoteAppliedPaymentsItem && equalTo((CreditNoteAppliedPaymentsItem) other);
42+
}
43+
44+
private boolean equalTo(CreditNoteAppliedPaymentsItem other) {
45+
return value.equals(other.value);
46+
}
47+
48+
@Override
49+
public int hashCode() {
50+
return Objects.hash(this.value);
51+
}
52+
53+
@Override
54+
public String toString() {
55+
return this.value.toString();
56+
}
57+
58+
public static CreditNoteAppliedPaymentsItem of(String value) {
59+
return new CreditNoteAppliedPaymentsItem(value, 0);
60+
}
61+
62+
public static CreditNoteAppliedPaymentsItem of(PaymentLineItem value) {
63+
return new CreditNoteAppliedPaymentsItem(value, 1);
64+
}
65+
66+
public interface Visitor<T> {
67+
T visit(String value);
68+
69+
T visit(PaymentLineItem value);
70+
}
71+
72+
static final class Deserializer extends StdDeserializer<CreditNoteAppliedPaymentsItem> {
73+
Deserializer() {
74+
super(CreditNoteAppliedPaymentsItem.class);
75+
}
76+
77+
@Override
78+
public CreditNoteAppliedPaymentsItem deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
79+
Object value = p.readValueAs(Object.class);
80+
try {
81+
return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class));
82+
} catch (IllegalArgumentException e) {
83+
}
84+
try {
85+
return of(ObjectMappers.JSON_MAPPER.convertValue(value, PaymentLineItem.class));
86+
} catch (IllegalArgumentException e) {
87+
}
88+
throw new JsonParseException(p, "Failed to deserialize");
89+
}
90+
}
91+
}

src/main/java/com/merge/api/resources/accounting/types/CreditNoteLineItem.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public final class CreditNoteLineItem {
4242

4343
private final Optional<String> remoteId;
4444

45+
private final Optional<Boolean> remoteWasDeleted;
46+
4547
private final Optional<OffsetDateTime> createdAt;
4648

4749
private final Optional<OffsetDateTime> modifiedAt;
@@ -60,6 +62,7 @@ private CreditNoteLineItem(
6062
Optional<String> account,
6163
Optional<CreditNoteLineItemCompany> company,
6264
Optional<String> remoteId,
65+
Optional<Boolean> remoteWasDeleted,
6366
Optional<OffsetDateTime> createdAt,
6467
Optional<OffsetDateTime> modifiedAt) {
6568
this.item = item;
@@ -75,6 +78,7 @@ private CreditNoteLineItem(
7578
this.account = account;
7679
this.company = company;
7780
this.remoteId = remoteId;
81+
this.remoteWasDeleted = remoteWasDeleted;
7882
this.createdAt = createdAt;
7983
this.modifiedAt = modifiedAt;
8084
}
@@ -180,6 +184,14 @@ public Optional<String> getRemoteId() {
180184
return remoteId;
181185
}
182186

187+
/**
188+
* @return Indicates whether or not this object has been deleted in the third party platform.
189+
*/
190+
@JsonProperty("remote_was_deleted")
191+
public Optional<Boolean> getRemoteWasDeleted() {
192+
return remoteWasDeleted;
193+
}
194+
183195
@JsonProperty("created_at")
184196
public Optional<OffsetDateTime> getCreatedAt() {
185197
return createdAt;
@@ -213,6 +225,7 @@ private boolean equalTo(CreditNoteLineItem other) {
213225
&& account.equals(other.account)
214226
&& company.equals(other.company)
215227
&& remoteId.equals(other.remoteId)
228+
&& remoteWasDeleted.equals(other.remoteWasDeleted)
216229
&& createdAt.equals(other.createdAt)
217230
&& modifiedAt.equals(other.modifiedAt);
218231
}
@@ -233,6 +246,7 @@ public int hashCode() {
233246
this.account,
234247
this.company,
235248
this.remoteId,
249+
this.remoteWasDeleted,
236250
this.createdAt,
237251
this.modifiedAt);
238252
}
@@ -274,6 +288,8 @@ public static final class Builder {
274288

275289
private Optional<String> remoteId = Optional.empty();
276290

291+
private Optional<Boolean> remoteWasDeleted = Optional.empty();
292+
277293
private Optional<OffsetDateTime> createdAt = Optional.empty();
278294

279295
private Optional<OffsetDateTime> modifiedAt = Optional.empty();
@@ -294,6 +310,7 @@ public Builder from(CreditNoteLineItem other) {
294310
account(other.getAccount());
295311
company(other.getCompany());
296312
remoteId(other.getRemoteId());
313+
remoteWasDeleted(other.getRemoteWasDeleted());
297314
createdAt(other.getCreatedAt());
298315
modifiedAt(other.getModifiedAt());
299316
return this;
@@ -448,6 +465,17 @@ public Builder remoteId(String remoteId) {
448465
return this;
449466
}
450467

468+
@JsonSetter(value = "remote_was_deleted", nulls = Nulls.SKIP)
469+
public Builder remoteWasDeleted(Optional<Boolean> remoteWasDeleted) {
470+
this.remoteWasDeleted = remoteWasDeleted;
471+
return this;
472+
}
473+
474+
public Builder remoteWasDeleted(Boolean remoteWasDeleted) {
475+
this.remoteWasDeleted = Optional.of(remoteWasDeleted);
476+
return this;
477+
}
478+
451479
@JsonSetter(value = "created_at", nulls = Nulls.SKIP)
452480
public Builder createdAt(Optional<OffsetDateTime> createdAt) {
453481
this.createdAt = createdAt;
@@ -485,6 +513,7 @@ public CreditNoteLineItem build() {
485513
account,
486514
company,
487515
remoteId,
516+
remoteWasDeleted,
488517
createdAt,
489518
modifiedAt);
490519
}

0 commit comments

Comments
 (0)