/
CreditReversal.java
241 lines (209 loc) · 8.72 KB
/
CreditReversal.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
// File generated from our OpenAPI spec
package com.stripe.model.treasury;
import com.google.gson.annotations.SerializedName;
import com.stripe.Stripe;
import com.stripe.exception.StripeException;
import com.stripe.model.ExpandableField;
import com.stripe.model.HasId;
import com.stripe.model.StripeObject;
import com.stripe.net.ApiResource;
import com.stripe.net.RequestOptions;
import com.stripe.param.treasury.CreditReversalCreateParams;
import com.stripe.param.treasury.CreditReversalListParams;
import com.stripe.param.treasury.CreditReversalRetrieveParams;
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* You can reverse some <a href="https://stripe.com/docs/api#received_credits">ReceivedCredits</a>
* depending on their network and source flow. Reversing a ReceivedCredit leads to the creation of a
* new object known as a CreditReversal.
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class CreditReversal extends ApiResource implements HasId {
/** Amount (in cents) transferred. */
@SerializedName("amount")
Long amount;
/** Time at which the object was created. Measured in seconds since the Unix epoch. */
@SerializedName("created")
Long created;
/**
* Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>,
* in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
*/
@SerializedName("currency")
String currency;
/** The FinancialAccount to reverse funds from. */
@SerializedName("financial_account")
String financialAccount;
/**
* A <a href="https://stripe.com/docs/treasury/moving-money/regulatory-receipts">hosted
* transaction receipt</a> URL that is provided when money movement is considered regulated under
* Stripe's money transmission licenses.
*/
@SerializedName("hosted_regulatory_receipt_url")
String hostedRegulatoryReceiptUrl;
/** Unique identifier for the object. */
@Getter(onMethod_ = {@Override})
@SerializedName("id")
String id;
/**
* Has the value {@code true} if the object exists in live mode or the value {@code false} if the
* object exists in test mode.
*/
@SerializedName("livemode")
Boolean livemode;
/**
* Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach
* to an object. This can be useful for storing additional information about the object in a
* structured format.
*/
@SerializedName("metadata")
Map<String, String> metadata;
/**
* The rails used to reverse the funds.
*
* <p>One of {@code ach}, or {@code stripe}.
*/
@SerializedName("network")
String network;
/**
* String representing the object's type. Objects of the same type share the same value.
*
* <p>Equal to {@code treasury.credit_reversal}.
*/
@SerializedName("object")
String object;
/** The ReceivedCredit being reversed. */
@SerializedName("received_credit")
String receivedCredit;
/**
* Status of the CreditReversal
*
* <p>One of {@code canceled}, {@code posted}, or {@code processing}.
*/
@SerializedName("status")
String status;
@SerializedName("status_transitions")
StatusTransitions statusTransitions;
/** The Transaction associated with this object. */
@SerializedName("transaction")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Transaction> transaction;
/** Get ID of expandable {@code transaction} object. */
public String getTransaction() {
return (this.transaction != null) ? this.transaction.getId() : null;
}
public void setTransaction(String id) {
this.transaction = ApiResource.setExpandableFieldId(id, this.transaction);
}
/** Get expanded {@code transaction}. */
public Transaction getTransactionObject() {
return (this.transaction != null) ? this.transaction.getExpanded() : null;
}
public void setTransactionObject(Transaction expandableObject) {
this.transaction = new ExpandableField<Transaction>(expandableObject.getId(), expandableObject);
}
/** Reverses a ReceivedCredit and creates a CreditReversal object. */
public static CreditReversal create(Map<String, Object> params) throws StripeException {
return create(params, (RequestOptions) null);
}
/** Reverses a ReceivedCredit and creates a CreditReversal object. */
public static CreditReversal create(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/treasury/credit_reversals");
return ApiResource.request(
ApiResource.RequestMethod.POST, url, params, CreditReversal.class, options);
}
/** Reverses a ReceivedCredit and creates a CreditReversal object. */
public static CreditReversal create(CreditReversalCreateParams params) throws StripeException {
return create(params, (RequestOptions) null);
}
/** Reverses a ReceivedCredit and creates a CreditReversal object. */
public static CreditReversal create(CreditReversalCreateParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/treasury/credit_reversals");
return ApiResource.request(
ApiResource.RequestMethod.POST, url, params, CreditReversal.class, options);
}
/** Returns a list of CreditReversals. */
public static CreditReversalCollection list(Map<String, Object> params) throws StripeException {
return list(params, (RequestOptions) null);
}
/** Returns a list of CreditReversals. */
public static CreditReversalCollection list(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/treasury/credit_reversals");
return ApiResource.requestCollection(url, params, CreditReversalCollection.class, options);
}
/** Returns a list of CreditReversals. */
public static CreditReversalCollection list(CreditReversalListParams params)
throws StripeException {
return list(params, (RequestOptions) null);
}
/** Returns a list of CreditReversals. */
public static CreditReversalCollection list(
CreditReversalListParams params, RequestOptions options) throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/treasury/credit_reversals");
return ApiResource.requestCollection(url, params, CreditReversalCollection.class, options);
}
/**
* Retrieves the details of an existing CreditReversal by passing the unique CreditReversal ID
* from either the CreditReversal creation request or CreditReversal list.
*/
public static CreditReversal retrieve(String creditReversal) throws StripeException {
return retrieve(creditReversal, (Map<String, Object>) null, (RequestOptions) null);
}
/**
* Retrieves the details of an existing CreditReversal by passing the unique CreditReversal ID
* from either the CreditReversal creation request or CreditReversal list.
*/
public static CreditReversal retrieve(String creditReversal, RequestOptions options)
throws StripeException {
return retrieve(creditReversal, (Map<String, Object>) null, options);
}
/**
* Retrieves the details of an existing CreditReversal by passing the unique CreditReversal ID
* from either the CreditReversal creation request or CreditReversal list.
*/
public static CreditReversal retrieve(
String creditReversal, Map<String, Object> params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
Stripe.getApiBase(),
String.format(
"/v1/treasury/credit_reversals/%s", ApiResource.urlEncodeId(creditReversal)));
return ApiResource.request(
ApiResource.RequestMethod.GET, url, params, CreditReversal.class, options);
}
/**
* Retrieves the details of an existing CreditReversal by passing the unique CreditReversal ID
* from either the CreditReversal creation request or CreditReversal list.
*/
public static CreditReversal retrieve(
String creditReversal, CreditReversalRetrieveParams params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
Stripe.getApiBase(),
String.format(
"/v1/treasury/credit_reversals/%s", ApiResource.urlEncodeId(creditReversal)));
return ApiResource.request(
ApiResource.RequestMethod.GET, url, params, CreditReversal.class, options);
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class StatusTransitions extends StripeObject {
/** Timestamp describing when the CreditReversal changed status to {@code posted}. */
@SerializedName("posted_at")
Long postedAt;
}
}