• 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/param/billing/CreditGrantCreateParams.java
1
// File generated from our OpenAPI spec
2
package com.stripe.param.billing;
3

4
import com.google.gson.annotations.SerializedName;
5
import com.stripe.net.ApiRequestParams;
6
import java.util.ArrayList;
7
import java.util.HashMap;
8
import java.util.List;
9
import java.util.Map;
10
import lombok.Getter;
11

12
@Getter
13
public class CreditGrantCreateParams extends ApiRequestParams {
14
  /** <strong>Required.</strong> Amount of this credit grant. */
15
  @SerializedName("amount")
16
  Amount amount;
17

18
  /** <strong>Required.</strong> Configuration specifying what this credit grant applies to. */
19
  @SerializedName("applicability_config")
20
  ApplicabilityConfig applicabilityConfig;
21

22
  /** <strong>Required.</strong> The category of this credit grant. */
23
  @SerializedName("category")
24
  Category category;
25

26
  /** <strong>Required.</strong> Id of the customer to whom the credit should be granted. */
27
  @SerializedName("customer")
28
  String customer;
29

30
  /**
31
   * The time when the credit becomes effective i.e when it is eligible to be used. Defaults to the
32
   * current timestamp if not specified.
33
   */
34
  @SerializedName("effective_at")
35
  Long effectiveAt;
36

37
  /** Specifies which fields in the response should be expanded. */
38
  @SerializedName("expand")
39
  List<String> expand;
40

41
  /** The time when the credit will expire. If not specified, the credit will never expire. */
42
  @SerializedName("expires_at")
43
  Long expiresAt;
44

45
  /**
46
   * Map of extra parameters for custom features not available in this client library. The content
47
   * in this map is not serialized under this field's {@code @SerializedName} value. Instead, each
48
   * key/value pair is serialized as if the key is a root-level field (serialized) name in this
49
   * param object. Effectively, this map is flattened to its parent instance.
50
   */
51
  @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY)
52
  Map<String, Object> extraParams;
53

54
  /**
55
   * Set of key-value pairs that you can attach to an object. This can be useful for storing
56
   * additional information about the object (ex: cost basis) in a structured format.
57
   */
58
  @SerializedName("metadata")
59
  Map<String, String> metadata;
60

61
  /** A descriptive name shown in dashboard and on invoices. */
62
  @SerializedName("name")
63
  String name;
64

65
  private CreditGrantCreateParams(
66
      Amount amount,
67
      ApplicabilityConfig applicabilityConfig,
68
      Category category,
69
      String customer,
70
      Long effectiveAt,
71
      List<String> expand,
72
      Long expiresAt,
73
      Map<String, Object> extraParams,
74
      Map<String, String> metadata,
NEW
75
      String name) {
×
NEW
76
    this.amount = amount;
×
NEW
77
    this.applicabilityConfig = applicabilityConfig;
×
NEW
78
    this.category = category;
×
NEW
79
    this.customer = customer;
×
NEW
80
    this.effectiveAt = effectiveAt;
×
NEW
81
    this.expand = expand;
×
NEW
82
    this.expiresAt = expiresAt;
×
NEW
83
    this.extraParams = extraParams;
×
NEW
84
    this.metadata = metadata;
×
NEW
85
    this.name = name;
×
NEW
86
  }
×
87

88
  public static Builder builder() {
NEW
89
    return new Builder();
×
90
  }
91

NEW
92
  public static class Builder {
×
93
    private Amount amount;
94

95
    private ApplicabilityConfig applicabilityConfig;
96

97
    private Category category;
98

99
    private String customer;
100

101
    private Long effectiveAt;
102

103
    private List<String> expand;
104

105
    private Long expiresAt;
106

107
    private Map<String, Object> extraParams;
108

109
    private Map<String, String> metadata;
110

111
    private String name;
112

113
    /** Finalize and obtain parameter instance from this builder. */
114
    public CreditGrantCreateParams build() {
NEW
115
      return new CreditGrantCreateParams(
×
116
          this.amount,
117
          this.applicabilityConfig,
118
          this.category,
119
          this.customer,
120
          this.effectiveAt,
121
          this.expand,
122
          this.expiresAt,
123
          this.extraParams,
124
          this.metadata,
125
          this.name);
126
    }
127

128
    /** <strong>Required.</strong> Amount of this credit grant. */
129
    public Builder setAmount(CreditGrantCreateParams.Amount amount) {
NEW
130
      this.amount = amount;
×
NEW
131
      return this;
×
132
    }
133

134
    /** <strong>Required.</strong> Configuration specifying what this credit grant applies to. */
135
    public Builder setApplicabilityConfig(
136
        CreditGrantCreateParams.ApplicabilityConfig applicabilityConfig) {
NEW
137
      this.applicabilityConfig = applicabilityConfig;
×
NEW
138
      return this;
×
139
    }
140

141
    /** <strong>Required.</strong> The category of this credit grant. */
142
    public Builder setCategory(CreditGrantCreateParams.Category category) {
NEW
143
      this.category = category;
×
NEW
144
      return this;
×
145
    }
146

147
    /** <strong>Required.</strong> Id of the customer to whom the credit should be granted. */
148
    public Builder setCustomer(String customer) {
NEW
149
      this.customer = customer;
×
NEW
150
      return this;
×
151
    }
152

153
    /**
154
     * The time when the credit becomes effective i.e when it is eligible to be used. Defaults to
155
     * the current timestamp if not specified.
156
     */
157
    public Builder setEffectiveAt(Long effectiveAt) {
NEW
158
      this.effectiveAt = effectiveAt;
×
NEW
159
      return this;
×
160
    }
161

162
    /**
163
     * Add an element to `expand` list. A list is initialized for the first `add/addAll` call, and
164
     * subsequent calls adds additional elements to the original list. See {@link
165
     * CreditGrantCreateParams#expand} for the field documentation.
166
     */
167
    public Builder addExpand(String element) {
NEW
168
      if (this.expand == null) {
×
NEW
169
        this.expand = new ArrayList<>();
×
170
      }
NEW
171
      this.expand.add(element);
×
NEW
172
      return this;
×
173
    }
174

175
    /**
176
     * Add all elements to `expand` list. A list is initialized for the first `add/addAll` call, and
177
     * subsequent calls adds additional elements to the original list. See {@link
178
     * CreditGrantCreateParams#expand} for the field documentation.
179
     */
180
    public Builder addAllExpand(List<String> elements) {
NEW
181
      if (this.expand == null) {
×
NEW
182
        this.expand = new ArrayList<>();
×
183
      }
NEW
184
      this.expand.addAll(elements);
×
NEW
185
      return this;
×
186
    }
187

188
    /** The time when the credit will expire. If not specified, the credit will never expire. */
189
    public Builder setExpiresAt(Long expiresAt) {
NEW
190
      this.expiresAt = expiresAt;
×
NEW
191
      return this;
×
192
    }
193

194
    /**
195
     * Add a key/value pair to `extraParams` map. A map is initialized for the first `put/putAll`
196
     * call, and subsequent calls add additional key/value pairs to the original map. See {@link
197
     * CreditGrantCreateParams#extraParams} for the field documentation.
198
     */
199
    public Builder putExtraParam(String key, Object value) {
NEW
200
      if (this.extraParams == null) {
×
NEW
201
        this.extraParams = new HashMap<>();
×
202
      }
NEW
203
      this.extraParams.put(key, value);
×
NEW
204
      return this;
×
205
    }
206

207
    /**
208
     * Add all map key/value pairs to `extraParams` map. A map is initialized for the first
209
     * `put/putAll` call, and subsequent calls add additional key/value pairs to the original map.
210
     * See {@link CreditGrantCreateParams#extraParams} for the field documentation.
211
     */
212
    public Builder putAllExtraParam(Map<String, Object> map) {
NEW
213
      if (this.extraParams == null) {
×
NEW
214
        this.extraParams = new HashMap<>();
×
215
      }
NEW
216
      this.extraParams.putAll(map);
×
NEW
217
      return this;
×
218
    }
219

220
    /**
221
     * Add a key/value pair to `metadata` map. A map is initialized for the first `put/putAll` call,
222
     * and subsequent calls add additional key/value pairs to the original map. See {@link
223
     * CreditGrantCreateParams#metadata} for the field documentation.
224
     */
225
    public Builder putMetadata(String key, String value) {
NEW
226
      if (this.metadata == null) {
×
NEW
227
        this.metadata = new HashMap<>();
×
228
      }
NEW
229
      this.metadata.put(key, value);
×
NEW
230
      return this;
×
231
    }
232

233
    /**
234
     * Add all map key/value pairs to `metadata` map. A map is initialized for the first
235
     * `put/putAll` call, and subsequent calls add additional key/value pairs to the original map.
236
     * See {@link CreditGrantCreateParams#metadata} for the field documentation.
237
     */
238
    public Builder putAllMetadata(Map<String, String> map) {
NEW
239
      if (this.metadata == null) {
×
NEW
240
        this.metadata = new HashMap<>();
×
241
      }
NEW
242
      this.metadata.putAll(map);
×
NEW
243
      return this;
×
244
    }
245

246
    /** A descriptive name shown in dashboard and on invoices. */
247
    public Builder setName(String name) {
NEW
248
      this.name = name;
×
NEW
249
      return this;
×
250
    }
251
  }
252

253
  @Getter
254
  public static class Amount {
255
    /**
256
     * Map of extra parameters for custom features not available in this client library. The content
257
     * in this map is not serialized under this field's {@code @SerializedName} value. Instead, each
258
     * key/value pair is serialized as if the key is a root-level field (serialized) name in this
259
     * param object. Effectively, this map is flattened to its parent instance.
260
     */
261
    @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY)
262
    Map<String, Object> extraParams;
263

264
    /** The monetary amount. */
265
    @SerializedName("monetary")
266
    Monetary monetary;
267

268
    /**
269
     * <strong>Required.</strong> Specify the type of this amount. We currently only support {@code
270
     * monetary} credits.
271
     */
272
    @SerializedName("type")
273
    Type type;
274

NEW
275
    private Amount(Map<String, Object> extraParams, Monetary monetary, Type type) {
×
NEW
276
      this.extraParams = extraParams;
×
NEW
277
      this.monetary = monetary;
×
NEW
278
      this.type = type;
×
NEW
279
    }
×
280

281
    public static Builder builder() {
NEW
282
      return new Builder();
×
283
    }
284

NEW
285
    public static class Builder {
×
286
      private Map<String, Object> extraParams;
287

288
      private Monetary monetary;
289

290
      private Type type;
291

292
      /** Finalize and obtain parameter instance from this builder. */
293
      public CreditGrantCreateParams.Amount build() {
NEW
294
        return new CreditGrantCreateParams.Amount(this.extraParams, this.monetary, this.type);
×
295
      }
296

297
      /**
298
       * Add a key/value pair to `extraParams` map. A map is initialized for the first `put/putAll`
299
       * call, and subsequent calls add additional key/value pairs to the original map. See {@link
300
       * CreditGrantCreateParams.Amount#extraParams} for the field documentation.
301
       */
302
      public Builder putExtraParam(String key, Object value) {
NEW
303
        if (this.extraParams == null) {
×
NEW
304
          this.extraParams = new HashMap<>();
×
305
        }
NEW
306
        this.extraParams.put(key, value);
×
NEW
307
        return this;
×
308
      }
309

310
      /**
311
       * Add all map key/value pairs to `extraParams` map. A map is initialized for the first
312
       * `put/putAll` call, and subsequent calls add additional key/value pairs to the original map.
313
       * See {@link CreditGrantCreateParams.Amount#extraParams} for the field documentation.
314
       */
315
      public Builder putAllExtraParam(Map<String, Object> map) {
NEW
316
        if (this.extraParams == null) {
×
NEW
317
          this.extraParams = new HashMap<>();
×
318
        }
NEW
319
        this.extraParams.putAll(map);
×
NEW
320
        return this;
×
321
      }
322

323
      /** The monetary amount. */
324
      public Builder setMonetary(CreditGrantCreateParams.Amount.Monetary monetary) {
NEW
325
        this.monetary = monetary;
×
NEW
326
        return this;
×
327
      }
328

329
      /**
330
       * <strong>Required.</strong> Specify the type of this amount. We currently only support
331
       * {@code monetary} credits.
332
       */
333
      public Builder setType(CreditGrantCreateParams.Amount.Type type) {
NEW
334
        this.type = type;
×
NEW
335
        return this;
×
336
      }
337
    }
338

339
    @Getter
340
    public static class Monetary {
341
      /**
342
       * <strong>Required.</strong> Three-letter <a href="https://stripe.com/docs/currencies">ISO
343
       * code for the currency</a> of the {@code value} parameter.
344
       */
345
      @SerializedName("currency")
346
      String currency;
347

348
      /**
349
       * Map of extra parameters for custom features not available in this client library. The
350
       * content in this map is not serialized under this field's {@code @SerializedName} value.
351
       * Instead, each key/value pair is serialized as if the key is a root-level field (serialized)
352
       * name in this param object. Effectively, this map is flattened to its parent instance.
353
       */
354
      @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY)
355
      Map<String, Object> extraParams;
356

357
      /**
358
       * <strong>Required.</strong> A positive integer representing the amount of the credit grant.
359
       */
360
      @SerializedName("value")
361
      Long value;
362

NEW
363
      private Monetary(String currency, Map<String, Object> extraParams, Long value) {
×
NEW
364
        this.currency = currency;
×
NEW
365
        this.extraParams = extraParams;
×
NEW
366
        this.value = value;
×
NEW
367
      }
×
368

369
      public static Builder builder() {
NEW
370
        return new Builder();
×
371
      }
372

NEW
373
      public static class Builder {
×
374
        private String currency;
375

376
        private Map<String, Object> extraParams;
377

378
        private Long value;
379

380
        /** Finalize and obtain parameter instance from this builder. */
381
        public CreditGrantCreateParams.Amount.Monetary build() {
NEW
382
          return new CreditGrantCreateParams.Amount.Monetary(
×
383
              this.currency, this.extraParams, this.value);
384
        }
385

386
        /**
387
         * <strong>Required.</strong> Three-letter <a href="https://stripe.com/docs/currencies">ISO
388
         * code for the currency</a> of the {@code value} parameter.
389
         */
390
        public Builder setCurrency(String currency) {
NEW
391
          this.currency = currency;
×
NEW
392
          return this;
×
393
        }
394

395
        /**
396
         * Add a key/value pair to `extraParams` map. A map is initialized for the first
397
         * `put/putAll` call, and subsequent calls add additional key/value pairs to the original
398
         * map. See {@link CreditGrantCreateParams.Amount.Monetary#extraParams} for the field
399
         * documentation.
400
         */
401
        public Builder putExtraParam(String key, Object value) {
NEW
402
          if (this.extraParams == null) {
×
NEW
403
            this.extraParams = new HashMap<>();
×
404
          }
NEW
405
          this.extraParams.put(key, value);
×
NEW
406
          return this;
×
407
        }
408

409
        /**
410
         * Add all map key/value pairs to `extraParams` map. A map is initialized for the first
411
         * `put/putAll` call, and subsequent calls add additional key/value pairs to the original
412
         * map. See {@link CreditGrantCreateParams.Amount.Monetary#extraParams} for the field
413
         * documentation.
414
         */
415
        public Builder putAllExtraParam(Map<String, Object> map) {
NEW
416
          if (this.extraParams == null) {
×
NEW
417
            this.extraParams = new HashMap<>();
×
418
          }
NEW
419
          this.extraParams.putAll(map);
×
NEW
420
          return this;
×
421
        }
422

423
        /**
424
         * <strong>Required.</strong> A positive integer representing the amount of the credit
425
         * grant.
426
         */
427
        public Builder setValue(Long value) {
NEW
428
          this.value = value;
×
NEW
429
          return this;
×
430
        }
431
      }
432
    }
433

NEW
434
    public enum Type implements ApiRequestParams.EnumParam {
×
NEW
435
      @SerializedName("monetary")
×
436
      MONETARY("monetary");
437

438
      @Getter(onMethod_ = {@Override})
439
      private final String value;
440

NEW
441
      Type(String value) {
×
NEW
442
        this.value = value;
×
NEW
443
      }
×
444
    }
445
  }
446

447
  @Getter
448
  public static class ApplicabilityConfig {
449
    /**
450
     * Map of extra parameters for custom features not available in this client library. The content
451
     * in this map is not serialized under this field's {@code @SerializedName} value. Instead, each
452
     * key/value pair is serialized as if the key is a root-level field (serialized) name in this
453
     * param object. Effectively, this map is flattened to its parent instance.
454
     */
455
    @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY)
456
    Map<String, Object> extraParams;
457

458
    /** <strong>Required.</strong> Specify the scope of this applicability config. */
459
    @SerializedName("scope")
460
    Scope scope;
461

NEW
462
    private ApplicabilityConfig(Map<String, Object> extraParams, Scope scope) {
×
NEW
463
      this.extraParams = extraParams;
×
NEW
464
      this.scope = scope;
×
NEW
465
    }
×
466

467
    public static Builder builder() {
NEW
468
      return new Builder();
×
469
    }
470

NEW
471
    public static class Builder {
×
472
      private Map<String, Object> extraParams;
473

474
      private Scope scope;
475

476
      /** Finalize and obtain parameter instance from this builder. */
477
      public CreditGrantCreateParams.ApplicabilityConfig build() {
NEW
478
        return new CreditGrantCreateParams.ApplicabilityConfig(this.extraParams, this.scope);
×
479
      }
480

481
      /**
482
       * Add a key/value pair to `extraParams` map. A map is initialized for the first `put/putAll`
483
       * call, and subsequent calls add additional key/value pairs to the original map. See {@link
484
       * CreditGrantCreateParams.ApplicabilityConfig#extraParams} for the field documentation.
485
       */
486
      public Builder putExtraParam(String key, Object value) {
NEW
487
        if (this.extraParams == null) {
×
NEW
488
          this.extraParams = new HashMap<>();
×
489
        }
NEW
490
        this.extraParams.put(key, value);
×
NEW
491
        return this;
×
492
      }
493

494
      /**
495
       * Add all map key/value pairs to `extraParams` map. A map is initialized for the first
496
       * `put/putAll` call, and subsequent calls add additional key/value pairs to the original map.
497
       * See {@link CreditGrantCreateParams.ApplicabilityConfig#extraParams} for the field
498
       * documentation.
499
       */
500
      public Builder putAllExtraParam(Map<String, Object> map) {
NEW
501
        if (this.extraParams == null) {
×
NEW
502
          this.extraParams = new HashMap<>();
×
503
        }
NEW
504
        this.extraParams.putAll(map);
×
NEW
505
        return this;
×
506
      }
507

508
      /** <strong>Required.</strong> Specify the scope of this applicability config. */
509
      public Builder setScope(CreditGrantCreateParams.ApplicabilityConfig.Scope scope) {
NEW
510
        this.scope = scope;
×
NEW
511
        return this;
×
512
      }
513
    }
514

515
    @Getter
516
    public static class Scope {
517
      /**
518
       * Map of extra parameters for custom features not available in this client library. The
519
       * content in this map is not serialized under this field's {@code @SerializedName} value.
520
       * Instead, each key/value pair is serialized as if the key is a root-level field (serialized)
521
       * name in this param object. Effectively, this map is flattened to its parent instance.
522
       */
523
      @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY)
524
      Map<String, Object> extraParams;
525

526
      /**
527
       * <strong>Required.</strong> The price type to which credit grants can apply to. We currently
528
       * only support {@code metered} price type.
529
       */
530
      @SerializedName("price_type")
531
      PriceType priceType;
532

NEW
533
      private Scope(Map<String, Object> extraParams, PriceType priceType) {
×
NEW
534
        this.extraParams = extraParams;
×
NEW
535
        this.priceType = priceType;
×
NEW
536
      }
×
537

538
      public static Builder builder() {
NEW
539
        return new Builder();
×
540
      }
541

NEW
542
      public static class Builder {
×
543
        private Map<String, Object> extraParams;
544

545
        private PriceType priceType;
546

547
        /** Finalize and obtain parameter instance from this builder. */
548
        public CreditGrantCreateParams.ApplicabilityConfig.Scope build() {
NEW
549
          return new CreditGrantCreateParams.ApplicabilityConfig.Scope(
×
550
              this.extraParams, this.priceType);
551
        }
552

553
        /**
554
         * Add a key/value pair to `extraParams` map. A map is initialized for the first
555
         * `put/putAll` call, and subsequent calls add additional key/value pairs to the original
556
         * map. See {@link CreditGrantCreateParams.ApplicabilityConfig.Scope#extraParams} for the
557
         * field documentation.
558
         */
559
        public Builder putExtraParam(String key, Object value) {
NEW
560
          if (this.extraParams == null) {
×
NEW
561
            this.extraParams = new HashMap<>();
×
562
          }
NEW
563
          this.extraParams.put(key, value);
×
NEW
564
          return this;
×
565
        }
566

567
        /**
568
         * Add all map key/value pairs to `extraParams` map. A map is initialized for the first
569
         * `put/putAll` call, and subsequent calls add additional key/value pairs to the original
570
         * map. See {@link CreditGrantCreateParams.ApplicabilityConfig.Scope#extraParams} for the
571
         * field documentation.
572
         */
573
        public Builder putAllExtraParam(Map<String, Object> map) {
NEW
574
          if (this.extraParams == null) {
×
NEW
575
            this.extraParams = new HashMap<>();
×
576
          }
NEW
577
          this.extraParams.putAll(map);
×
NEW
578
          return this;
×
579
        }
580

581
        /**
582
         * <strong>Required.</strong> The price type to which credit grants can apply to. We
583
         * currently only support {@code metered} price type.
584
         */
585
        public Builder setPriceType(
586
            CreditGrantCreateParams.ApplicabilityConfig.Scope.PriceType priceType) {
NEW
587
          this.priceType = priceType;
×
NEW
588
          return this;
×
589
        }
590
      }
591

NEW
592
      public enum PriceType implements ApiRequestParams.EnumParam {
×
NEW
593
        @SerializedName("metered")
×
594
        METERED("metered");
595

596
        @Getter(onMethod_ = {@Override})
597
        private final String value;
598

NEW
599
        PriceType(String value) {
×
NEW
600
          this.value = value;
×
NEW
601
        }
×
602
      }
603
    }
604
  }
605

NEW
606
  public enum Category implements ApiRequestParams.EnumParam {
×
NEW
607
    @SerializedName("paid")
×
608
    PAID("paid"),
609

NEW
610
    @SerializedName("promotional")
×
611
    PROMOTIONAL("promotional");
612

613
    @Getter(onMethod_ = {@Override})
614
    private final String value;
615

NEW
616
    Category(String value) {
×
NEW
617
      this.value = value;
×
NEW
618
    }
×
619
  }
620
}
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