Skip to content

Commit 28de1d0

Browse files
authored
Regenerate with decimal_string enabled for v2 APIs (#2187)
1 parent 150d985 commit 28de1d0

9 files changed

Lines changed: 55 additions & 20 deletions

File tree

src/main/java/com/stripe/model/v2/core/Account.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.stripe.model.HasId;
66
import com.stripe.model.StripeObject;
77
import com.stripe.v2.Amount;
8+
import java.math.BigDecimal;
89
import java.time.Instant;
910
import java.util.List;
1011
import java.util.Map;
@@ -5345,7 +5346,7 @@ public static class Relationship extends StripeObject {
53455346

53465347
/** The percentage of the Account's identity that the individual owns. */
53475348
@SerializedName("percent_ownership")
5348-
String percentOwnership;
5349+
BigDecimal percentOwnership;
53495350

53505351
/**
53515352
* Whether the individual is authorized as the primary representative of the Account. This

src/main/java/com/stripe/model/v2/core/AccountPerson.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.gson.annotations.SerializedName;
55
import com.stripe.model.HasId;
66
import com.stripe.model.StripeObject;
7+
import java.math.BigDecimal;
78
import java.time.Instant;
89
import java.util.List;
910
import java.util.Map;
@@ -584,7 +585,7 @@ public static class Relationship extends StripeObject {
584585

585586
/** The percentage of the Account's identity that the individual owns. */
586587
@SerializedName("percent_ownership")
587-
String percentOwnership;
588+
BigDecimal percentOwnership;
588589

589590
/**
590591
* Whether the individual is authorized as the primary representative of the Account. This is

src/main/java/com/stripe/net/JsonEncoder.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,42 @@
33
import com.google.gson.FieldNamingPolicy;
44
import com.google.gson.Gson;
55
import com.google.gson.GsonBuilder;
6+
import com.google.gson.TypeAdapter;
7+
import com.google.gson.stream.JsonReader;
8+
import com.google.gson.stream.JsonWriter;
69
import java.io.IOException;
10+
import java.math.BigDecimal;
711
import java.util.HashMap;
812
import java.util.Map;
913

1014
final class JsonEncoder {
15+
/**
16+
* Serializes BigDecimal as a JSON string (e.g., "25.5") rather than a JSON number (25.5). All
17+
* BigDecimal fields in the Stripe API use format: decimal, and the V2 API expects them as strings
18+
* on the wire.
19+
*/
20+
private static final TypeAdapter<BigDecimal> BIG_DECIMAL_STRING_ADAPTER =
21+
new TypeAdapter<BigDecimal>() {
22+
@Override
23+
public void write(JsonWriter out, BigDecimal value) throws IOException {
24+
if (value == null) {
25+
out.nullValue();
26+
} else {
27+
out.value(value.toPlainString());
28+
}
29+
}
30+
31+
@Override
32+
public BigDecimal read(JsonReader in) throws IOException {
33+
return new BigDecimal(in.nextString());
34+
}
35+
};
36+
1137
private static final Gson BODY_GSON =
1238
new GsonBuilder()
1339
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
1440
.serializeNulls()
41+
.registerTypeAdapter(BigDecimal.class, BIG_DECIMAL_STRING_ADAPTER)
1542
.create();
1643

1744
public static HttpContent createHttpContent(Map<String, Object> params) throws IOException {

src/main/java/com/stripe/param/v2/core/AccountCreateParams.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.gson.annotations.SerializedName;
55
import com.stripe.net.ApiRequestParams;
66
import com.stripe.v2.Amount;
7+
import java.math.BigDecimal;
78
import java.time.Instant;
89
import java.util.ArrayList;
910
import java.util.HashMap;
@@ -15655,7 +15656,7 @@ public static class Relationship {
1565515656

1565615657
/** The percent owned by the person of the account's legal entity. */
1565715658
@SerializedName("percent_ownership")
15658-
String percentOwnership;
15659+
BigDecimal percentOwnership;
1565915660

1566015661
/** The person's title (e.g., CEO, Support Engineer). */
1566115662
@SerializedName("title")
@@ -15666,7 +15667,7 @@ private Relationship(
1566615667
Boolean executive,
1566715668
Map<String, Object> extraParams,
1566815669
Boolean owner,
15669-
String percentOwnership,
15670+
BigDecimal percentOwnership,
1567015671
String title) {
1567115672
this.director = director;
1567215673
this.executive = executive;
@@ -15689,7 +15690,7 @@ public static class Builder {
1568915690

1569015691
private Boolean owner;
1569115692

15692-
private String percentOwnership;
15693+
private BigDecimal percentOwnership;
1569315694

1569415695
private String title;
1569515696

@@ -15758,7 +15759,7 @@ public Builder setOwner(Boolean owner) {
1575815759
}
1575915760

1576015761
/** The percent owned by the person of the account's legal entity. */
15761-
public Builder setPercentOwnership(String percentOwnership) {
15762+
public Builder setPercentOwnership(BigDecimal percentOwnership) {
1576215763
this.percentOwnership = percentOwnership;
1576315764
return this;
1576415765
}

src/main/java/com/stripe/param/v2/core/AccountTokenCreateParams.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.stripe.net.ApiRequestParams;
66
import com.stripe.param.common.EmptyParam;
77
import com.stripe.v2.Amount;
8+
import java.math.BigDecimal;
89
import java.util.ArrayList;
910
import java.util.HashMap;
1011
import java.util.List;
@@ -7123,7 +7124,7 @@ public static class Relationship {
71237124

71247125
/** The percent owned by the person of the account's legal entity. */
71257126
@SerializedName("percent_ownership")
7126-
String percentOwnership;
7127+
BigDecimal percentOwnership;
71277128

71287129
/** The person's title (e.g., CEO, Support Engineer). */
71297130
@SerializedName("title")
@@ -7134,7 +7135,7 @@ private Relationship(
71347135
Boolean executive,
71357136
Map<String, Object> extraParams,
71367137
Boolean owner,
7137-
String percentOwnership,
7138+
BigDecimal percentOwnership,
71387139
String title) {
71397140
this.director = director;
71407141
this.executive = executive;
@@ -7157,7 +7158,7 @@ public static class Builder {
71577158

71587159
private Boolean owner;
71597160

7160-
private String percentOwnership;
7161+
private BigDecimal percentOwnership;
71617162

71627163
private String title;
71637164

@@ -7226,7 +7227,7 @@ public Builder setOwner(Boolean owner) {
72267227
}
72277228

72287229
/** The percent owned by the person of the account's legal entity. */
7229-
public Builder setPercentOwnership(String percentOwnership) {
7230+
public Builder setPercentOwnership(BigDecimal percentOwnership) {
72307231
this.percentOwnership = percentOwnership;
72317232
return this;
72327233
}

src/main/java/com/stripe/param/v2/core/AccountUpdateParams.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.stripe.net.ApiRequestParams;
66
import com.stripe.param.common.EmptyParam;
77
import com.stripe.v2.Amount;
8+
import java.math.BigDecimal;
89
import java.time.Instant;
910
import java.util.ArrayList;
1011
import java.util.HashMap;
@@ -17078,7 +17079,7 @@ public Builder setOwner(Boolean owner) {
1707817079
}
1707917080

1708017081
/** The percent owned by the person of the account's legal entity. */
17081-
public Builder setPercentOwnership(String percentOwnership) {
17082+
public Builder setPercentOwnership(BigDecimal percentOwnership) {
1708217083
this.percentOwnership = percentOwnership;
1708317084
return this;
1708417085
}

src/main/java/com/stripe/param/v2/core/accounts/PersonCreateParams.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import com.google.gson.annotations.SerializedName;
55
import com.stripe.net.ApiRequestParams;
6+
import java.math.BigDecimal;
67
import java.time.Instant;
78
import java.util.ArrayList;
89
import java.util.HashMap;
@@ -2575,7 +2576,7 @@ public static class Relationship {
25752576

25762577
/** The percentage of ownership the person has in the associated legal entity. */
25772578
@SerializedName("percent_ownership")
2578-
String percentOwnership;
2579+
BigDecimal percentOwnership;
25792580

25802581
/** Indicates whether the person is a representative of the associated legal entity. */
25812582
@SerializedName("representative")
@@ -2592,7 +2593,7 @@ private Relationship(
25922593
Map<String, Object> extraParams,
25932594
Boolean legalGuardian,
25942595
Boolean owner,
2595-
String percentOwnership,
2596+
BigDecimal percentOwnership,
25962597
Boolean representative,
25972598
String title) {
25982599
this.authorizer = authorizer;
@@ -2623,7 +2624,7 @@ public static class Builder {
26232624

26242625
private Boolean owner;
26252626

2626-
private String percentOwnership;
2627+
private BigDecimal percentOwnership;
26272628

26282629
private Boolean representative;
26292630

@@ -2700,7 +2701,7 @@ public Builder setOwner(Boolean owner) {
27002701
}
27012702

27022703
/** The percentage of ownership the person has in the associated legal entity. */
2703-
public Builder setPercentOwnership(String percentOwnership) {
2704+
public Builder setPercentOwnership(BigDecimal percentOwnership) {
27042705
this.percentOwnership = percentOwnership;
27052706
return this;
27062707
}

src/main/java/com/stripe/param/v2/core/accounts/PersonTokenCreateParams.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.gson.annotations.SerializedName;
55
import com.stripe.net.ApiRequestParams;
66
import com.stripe.param.common.EmptyParam;
7+
import java.math.BigDecimal;
78
import java.util.ArrayList;
89
import java.util.HashMap;
910
import java.util.List;
@@ -2545,7 +2546,7 @@ public static class Relationship {
25452546

25462547
/** The percentage of ownership the person has in the associated legal entity. */
25472548
@SerializedName("percent_ownership")
2548-
String percentOwnership;
2549+
BigDecimal percentOwnership;
25492550

25502551
/** Indicates whether the person is a representative of the associated legal entity. */
25512552
@SerializedName("representative")
@@ -2562,7 +2563,7 @@ private Relationship(
25622563
Map<String, Object> extraParams,
25632564
Boolean legalGuardian,
25642565
Boolean owner,
2565-
String percentOwnership,
2566+
BigDecimal percentOwnership,
25662567
Boolean representative,
25672568
String title) {
25682569
this.authorizer = authorizer;
@@ -2593,7 +2594,7 @@ public static class Builder {
25932594

25942595
private Boolean owner;
25952596

2596-
private String percentOwnership;
2597+
private BigDecimal percentOwnership;
25972598

25982599
private Boolean representative;
25992600

@@ -2670,7 +2671,7 @@ public Builder setOwner(Boolean owner) {
26702671
}
26712672

26722673
/** The percentage of ownership the person has in the associated legal entity. */
2673-
public Builder setPercentOwnership(String percentOwnership) {
2674+
public Builder setPercentOwnership(BigDecimal percentOwnership) {
26742675
this.percentOwnership = percentOwnership;
26752676
return this;
26762677
}

src/main/java/com/stripe/param/v2/core/accounts/PersonUpdateParams.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.gson.annotations.SerializedName;
55
import com.stripe.net.ApiRequestParams;
66
import com.stripe.param.common.EmptyParam;
7+
import java.math.BigDecimal;
78
import java.time.Instant;
89
import java.util.ArrayList;
910
import java.util.HashMap;
@@ -2918,7 +2919,7 @@ public Builder setOwner(Boolean owner) {
29182919
}
29192920

29202921
/** The percentage of ownership the person has in the associated legal entity. */
2921-
public Builder setPercentOwnership(String percentOwnership) {
2922+
public Builder setPercentOwnership(BigDecimal percentOwnership) {
29222923
this.percentOwnership = percentOwnership;
29232924
return this;
29242925
}

0 commit comments

Comments
 (0)