• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-java / #16493

03 Oct 2024 07:15PM UTC coverage: 12.942% (+0.08%) from 12.864%
#16493

push

github

web-flow
Merge Stripe-java v27.0.0 to beta branch (#1888)

409 of 1651 new or added lines in 88 files covered. (24.77%)

31 existing lines in 7 files now uncovered.

18773 of 145050 relevant lines covered (12.94%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/stripe/model/billing/CreditGrant.java
1
// File generated from our OpenAPI spec
2
package com.stripe.model.billing;
3

4
import com.google.gson.annotations.SerializedName;
5
import com.stripe.exception.StripeException;
6
import com.stripe.model.Customer;
7
import com.stripe.model.ExpandableField;
8
import com.stripe.model.HasId;
9
import com.stripe.model.MetadataStore;
10
import com.stripe.model.StripeObject;
11
import com.stripe.model.testhelpers.TestClock;
12
import com.stripe.net.ApiRequest;
13
import com.stripe.net.ApiRequestParams;
14
import com.stripe.net.ApiResource;
15
import com.stripe.net.BaseAddress;
16
import com.stripe.net.RequestOptions;
17
import com.stripe.net.StripeResponseGetter;
18
import com.stripe.param.billing.CreditGrantCreateParams;
19
import com.stripe.param.billing.CreditGrantExpireParams;
20
import com.stripe.param.billing.CreditGrantListParams;
21
import com.stripe.param.billing.CreditGrantRetrieveParams;
22
import com.stripe.param.billing.CreditGrantUpdateParams;
23
import com.stripe.param.billing.CreditGrantVoidGrantParams;
24
import java.util.Map;
25
import lombok.EqualsAndHashCode;
26
import lombok.Getter;
27
import lombok.Setter;
28

29
/** A credit grant is a resource that records a grant of some credit to a customer. */
30
@Getter
31
@Setter
32
@EqualsAndHashCode(callSuper = false)
NEW
33
public class CreditGrant extends ApiResource implements HasId, MetadataStore<CreditGrant> {
×
34
  @SerializedName("amount")
35
  Amount amount;
36

37
  @SerializedName("applicability_config")
38
  ApplicabilityConfig applicabilityConfig;
39

40
  /**
41
   * The category of this credit grant.
42
   *
43
   * <p>One of {@code paid}, or {@code promotional}.
44
   */
45
  @SerializedName("category")
46
  String category;
47

48
  /** Time at which the object was created. Measured in seconds since the Unix epoch. */
49
  @SerializedName("created")
50
  Long created;
51

52
  /** Id of the customer to whom the credit was granted. */
53
  @SerializedName("customer")
54
  @Getter(lombok.AccessLevel.NONE)
55
  @Setter(lombok.AccessLevel.NONE)
56
  ExpandableField<Customer> customer;
57

58
  /** The time when the credit becomes effective i.e when it is eligible to be used. */
59
  @SerializedName("effective_at")
60
  Long effectiveAt;
61

62
  /** The time when the credit will expire. If not present, the credit will never expire. */
63
  @SerializedName("expires_at")
64
  Long expiresAt;
65

66
  /** Unique identifier for the object. */
67
  @Getter(onMethod_ = {@Override})
68
  @SerializedName("id")
69
  String id;
70

71
  /**
72
   * Has the value {@code true} if the object exists in live mode or the value {@code false} if the
73
   * object exists in test mode.
74
   */
75
  @SerializedName("livemode")
76
  Boolean livemode;
77

78
  /**
79
   * Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach
80
   * to an object. This can be useful for storing additional information about the object in a
81
   * structured format.
82
   */
83
  @Getter(onMethod_ = {@Override})
84
  @SerializedName("metadata")
85
  Map<String, String> metadata;
86

87
  /** A descriptive name shown in dashboard and on invoices. */
88
  @SerializedName("name")
89
  String name;
90

91
  /**
92
   * String representing the object's type. Objects of the same type share the same value.
93
   *
94
   * <p>Equal to {@code billing.credit_grant}.
95
   */
96
  @SerializedName("object")
97
  String object;
98

99
  /** ID of the test clock this credit grant belongs to. */
100
  @SerializedName("test_clock")
101
  @Getter(lombok.AccessLevel.NONE)
102
  @Setter(lombok.AccessLevel.NONE)
103
  ExpandableField<TestClock> testClock;
104

105
  /** Time at which the object was last updated. Measured in seconds since the Unix epoch. */
106
  @SerializedName("updated")
107
  Long updated;
108

109
  /**
110
   * The time when this credit grant was voided. If not present, the credit grant hasn't been
111
   * voided.
112
   */
113
  @SerializedName("voided_at")
114
  Long voidedAt;
115

116
  /** Get ID of expandable {@code customer} object. */
117
  public String getCustomer() {
NEW
118
    return (this.customer != null) ? this.customer.getId() : null;
×
119
  }
120

121
  public void setCustomer(String id) {
NEW
122
    this.customer = ApiResource.setExpandableFieldId(id, this.customer);
×
NEW
123
  }
×
124

125
  /** Get expanded {@code customer}. */
126
  public Customer getCustomerObject() {
NEW
127
    return (this.customer != null) ? this.customer.getExpanded() : null;
×
128
  }
129

130
  public void setCustomerObject(Customer expandableObject) {
NEW
131
    this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
×
NEW
132
  }
×
133

134
  /** Get ID of expandable {@code testClock} object. */
135
  public String getTestClock() {
NEW
136
    return (this.testClock != null) ? this.testClock.getId() : null;
×
137
  }
138

139
  public void setTestClock(String id) {
NEW
140
    this.testClock = ApiResource.setExpandableFieldId(id, this.testClock);
×
NEW
141
  }
×
142

143
  /** Get expanded {@code testClock}. */
144
  public TestClock getTestClockObject() {
NEW
145
    return (this.testClock != null) ? this.testClock.getExpanded() : null;
×
146
  }
147

148
  public void setTestClockObject(TestClock expandableObject) {
NEW
149
    this.testClock = new ExpandableField<TestClock>(expandableObject.getId(), expandableObject);
×
NEW
150
  }
×
151

152
  /** Creates a credit grant. */
153
  public static CreditGrant create(Map<String, Object> params) throws StripeException {
NEW
154
    return create(params, (RequestOptions) null);
×
155
  }
156

157
  /** Creates a credit grant. */
158
  public static CreditGrant create(Map<String, Object> params, RequestOptions options)
159
      throws StripeException {
NEW
160
    String path = "/v1/billing/credit_grants";
×
NEW
161
    ApiRequest request =
×
162
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
NEW
163
    return getGlobalResponseGetter().request(request, CreditGrant.class);
×
164
  }
165

166
  /** Creates a credit grant. */
167
  public static CreditGrant create(CreditGrantCreateParams params) throws StripeException {
NEW
168
    return create(params, (RequestOptions) null);
×
169
  }
170

171
  /** Creates a credit grant. */
172
  public static CreditGrant create(CreditGrantCreateParams params, RequestOptions options)
173
      throws StripeException {
NEW
174
    String path = "/v1/billing/credit_grants";
×
NEW
175
    ApiResource.checkNullTypedParams(path, params);
×
NEW
176
    ApiRequest request =
×
177
        new ApiRequest(
178
            BaseAddress.API,
179
            ApiResource.RequestMethod.POST,
180
            path,
NEW
181
            ApiRequestParams.paramsToMap(params),
×
182
            options);
NEW
183
    return getGlobalResponseGetter().request(request, CreditGrant.class);
×
184
  }
185

186
  /** Expires a credit grant. */
187
  public CreditGrant expire() throws StripeException {
NEW
188
    return expire((Map<String, Object>) null, (RequestOptions) null);
×
189
  }
190

191
  /** Expires a credit grant. */
192
  public CreditGrant expire(RequestOptions options) throws StripeException {
NEW
193
    return expire((Map<String, Object>) null, options);
×
194
  }
195

196
  /** Expires a credit grant. */
197
  public CreditGrant expire(Map<String, Object> params) throws StripeException {
NEW
198
    return expire(params, (RequestOptions) null);
×
199
  }
200

201
  /** Expires a credit grant. */
202
  public CreditGrant expire(Map<String, Object> params, RequestOptions options)
203
      throws StripeException {
NEW
204
    String path =
×
NEW
205
        String.format("/v1/billing/credit_grants/%s/expire", ApiResource.urlEncodeId(this.getId()));
×
NEW
206
    ApiRequest request =
×
207
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
NEW
208
    return getResponseGetter().request(request, CreditGrant.class);
×
209
  }
210

211
  /** Expires a credit grant. */
212
  public CreditGrant expire(CreditGrantExpireParams params) throws StripeException {
NEW
213
    return expire(params, (RequestOptions) null);
×
214
  }
215

216
  /** Expires a credit grant. */
217
  public CreditGrant expire(CreditGrantExpireParams params, RequestOptions options)
218
      throws StripeException {
NEW
219
    String path =
×
NEW
220
        String.format("/v1/billing/credit_grants/%s/expire", ApiResource.urlEncodeId(this.getId()));
×
NEW
221
    ApiResource.checkNullTypedParams(path, params);
×
NEW
222
    ApiRequest request =
×
223
        new ApiRequest(
224
            BaseAddress.API,
225
            ApiResource.RequestMethod.POST,
226
            path,
NEW
227
            ApiRequestParams.paramsToMap(params),
×
228
            options);
NEW
229
    return getResponseGetter().request(request, CreditGrant.class);
×
230
  }
231

232
  /** Retrieve a list of credit grants. */
233
  public static CreditGrantCollection list(Map<String, Object> params) throws StripeException {
NEW
234
    return list(params, (RequestOptions) null);
×
235
  }
236

237
  /** Retrieve a list of credit grants. */
238
  public static CreditGrantCollection list(Map<String, Object> params, RequestOptions options)
239
      throws StripeException {
NEW
240
    String path = "/v1/billing/credit_grants";
×
NEW
241
    ApiRequest request =
×
242
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
NEW
243
    return getGlobalResponseGetter().request(request, CreditGrantCollection.class);
×
244
  }
245

246
  /** Retrieve a list of credit grants. */
247
  public static CreditGrantCollection list(CreditGrantListParams params) throws StripeException {
NEW
248
    return list(params, (RequestOptions) null);
×
249
  }
250

251
  /** Retrieve a list of credit grants. */
252
  public static CreditGrantCollection list(CreditGrantListParams params, RequestOptions options)
253
      throws StripeException {
NEW
254
    String path = "/v1/billing/credit_grants";
×
NEW
255
    ApiResource.checkNullTypedParams(path, params);
×
NEW
256
    ApiRequest request =
×
257
        new ApiRequest(
258
            BaseAddress.API,
259
            ApiResource.RequestMethod.GET,
260
            path,
NEW
261
            ApiRequestParams.paramsToMap(params),
×
262
            options);
NEW
263
    return getGlobalResponseGetter().request(request, CreditGrantCollection.class);
×
264
  }
265

266
  /** Retrieves a credit grant. */
267
  public static CreditGrant retrieve(String id) throws StripeException {
NEW
268
    return retrieve(id, (Map<String, Object>) null, (RequestOptions) null);
×
269
  }
270

271
  /** Retrieves a credit grant. */
272
  public static CreditGrant retrieve(String id, RequestOptions options) throws StripeException {
NEW
273
    return retrieve(id, (Map<String, Object>) null, options);
×
274
  }
275

276
  /** Retrieves a credit grant. */
277
  public static CreditGrant retrieve(String id, Map<String, Object> params, RequestOptions options)
278
      throws StripeException {
NEW
279
    String path = String.format("/v1/billing/credit_grants/%s", ApiResource.urlEncodeId(id));
×
NEW
280
    ApiRequest request =
×
281
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
NEW
282
    return getGlobalResponseGetter().request(request, CreditGrant.class);
×
283
  }
284

285
  /** Retrieves a credit grant. */
286
  public static CreditGrant retrieve(
287
      String id, CreditGrantRetrieveParams params, RequestOptions options) throws StripeException {
NEW
288
    String path = String.format("/v1/billing/credit_grants/%s", ApiResource.urlEncodeId(id));
×
NEW
289
    ApiResource.checkNullTypedParams(path, params);
×
NEW
290
    ApiRequest request =
×
291
        new ApiRequest(
292
            BaseAddress.API,
293
            ApiResource.RequestMethod.GET,
294
            path,
NEW
295
            ApiRequestParams.paramsToMap(params),
×
296
            options);
NEW
297
    return getGlobalResponseGetter().request(request, CreditGrant.class);
×
298
  }
299

300
  /** Updates a credit grant. */
301
  @Override
302
  public CreditGrant update(Map<String, Object> params) throws StripeException {
NEW
303
    return update(params, (RequestOptions) null);
×
304
  }
305

306
  /** Updates a credit grant. */
307
  @Override
308
  public CreditGrant update(Map<String, Object> params, RequestOptions options)
309
      throws StripeException {
NEW
310
    String path =
×
NEW
311
        String.format("/v1/billing/credit_grants/%s", ApiResource.urlEncodeId(this.getId()));
×
NEW
312
    ApiRequest request =
×
313
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
NEW
314
    return getResponseGetter().request(request, CreditGrant.class);
×
315
  }
316

317
  /** Updates a credit grant. */
318
  public CreditGrant update(CreditGrantUpdateParams params) throws StripeException {
NEW
319
    return update(params, (RequestOptions) null);
×
320
  }
321

322
  /** Updates a credit grant. */
323
  public CreditGrant update(CreditGrantUpdateParams params, RequestOptions options)
324
      throws StripeException {
NEW
325
    String path =
×
NEW
326
        String.format("/v1/billing/credit_grants/%s", ApiResource.urlEncodeId(this.getId()));
×
NEW
327
    ApiResource.checkNullTypedParams(path, params);
×
NEW
328
    ApiRequest request =
×
329
        new ApiRequest(
330
            BaseAddress.API,
331
            ApiResource.RequestMethod.POST,
332
            path,
NEW
333
            ApiRequestParams.paramsToMap(params),
×
334
            options);
NEW
335
    return getResponseGetter().request(request, CreditGrant.class);
×
336
  }
337

338
  /** Voids a credit grant. */
339
  public CreditGrant voidGrant() throws StripeException {
NEW
340
    return voidGrant((Map<String, Object>) null, (RequestOptions) null);
×
341
  }
342

343
  /** Voids a credit grant. */
344
  public CreditGrant voidGrant(RequestOptions options) throws StripeException {
NEW
345
    return voidGrant((Map<String, Object>) null, options);
×
346
  }
347

348
  /** Voids a credit grant. */
349
  public CreditGrant voidGrant(Map<String, Object> params) throws StripeException {
NEW
350
    return voidGrant(params, (RequestOptions) null);
×
351
  }
352

353
  /** Voids a credit grant. */
354
  public CreditGrant voidGrant(Map<String, Object> params, RequestOptions options)
355
      throws StripeException {
NEW
356
    String path =
×
NEW
357
        String.format("/v1/billing/credit_grants/%s/void", ApiResource.urlEncodeId(this.getId()));
×
NEW
358
    ApiRequest request =
×
359
        new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options);
NEW
360
    return getResponseGetter().request(request, CreditGrant.class);
×
361
  }
362

363
  /** Voids a credit grant. */
364
  public CreditGrant voidGrant(CreditGrantVoidGrantParams params) throws StripeException {
NEW
365
    return voidGrant(params, (RequestOptions) null);
×
366
  }
367

368
  /** Voids a credit grant. */
369
  public CreditGrant voidGrant(CreditGrantVoidGrantParams params, RequestOptions options)
370
      throws StripeException {
NEW
371
    String path =
×
NEW
372
        String.format("/v1/billing/credit_grants/%s/void", ApiResource.urlEncodeId(this.getId()));
×
NEW
373
    ApiResource.checkNullTypedParams(path, params);
×
NEW
374
    ApiRequest request =
×
375
        new ApiRequest(
376
            BaseAddress.API,
377
            ApiResource.RequestMethod.POST,
378
            path,
NEW
379
            ApiRequestParams.paramsToMap(params),
×
380
            options);
NEW
381
    return getResponseGetter().request(request, CreditGrant.class);
×
382
  }
383

384
  @Getter
385
  @Setter
386
  @EqualsAndHashCode(callSuper = false)
NEW
387
  public static class Amount extends StripeObject {
×
388
    /** The monetary amount. */
389
    @SerializedName("monetary")
390
    Monetary monetary;
391

392
    /**
393
     * The type of this amount. We currently only support {@code monetary} credits.
394
     *
395
     * <p>Equal to {@code monetary}.
396
     */
397
    @SerializedName("type")
398
    String type;
399

400
    @Getter
401
    @Setter
402
    @EqualsAndHashCode(callSuper = false)
NEW
403
    public static class Monetary extends StripeObject {
×
404
      /**
405
       * Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency
406
       * code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported
407
       * currency</a>.
408
       */
409
      @SerializedName("currency")
410
      String currency;
411

412
      /** A positive integer representing the amount. */
413
      @SerializedName("value")
414
      Long value;
415
    }
416
  }
417

418
  @Getter
419
  @Setter
420
  @EqualsAndHashCode(callSuper = false)
NEW
421
  public static class ApplicabilityConfig extends StripeObject {
×
422
    @SerializedName("scope")
423
    Scope scope;
424

425
    @Getter
426
    @Setter
427
    @EqualsAndHashCode(callSuper = false)
NEW
428
    public static class Scope extends StripeObject {
×
429
      /**
430
       * The price type to which credit grants can apply to. We currently only support {@code
431
       * metered} price type.
432
       *
433
       * <p>Equal to {@code metered}.
434
       */
435
      @SerializedName("price_type")
436
      String priceType;
437
    }
438
  }
439

440
  @Override
441
  public void setResponseGetter(StripeResponseGetter responseGetter) {
NEW
442
    super.setResponseGetter(responseGetter);
×
NEW
443
    trySetResponseGetter(amount, responseGetter);
×
NEW
444
    trySetResponseGetter(applicabilityConfig, responseGetter);
×
NEW
445
    trySetResponseGetter(customer, responseGetter);
×
NEW
446
    trySetResponseGetter(testClock, responseGetter);
×
NEW
447
  }
×
448
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc