Repository navigation
Expand file tree
/
Copy pathWallet.java
More file actions
796 lines (722 loc) · 29.6 KB
/
Copy pathWallet.java
File metadata and controls
796 lines (722 loc) · 29.6 KB
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
// This file is @generated
package com.meteroid.models;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import com.meteroid.internal.JsonField;
import com.meteroid.internal.Utils;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
/**
* A customer's credit in one currency or credit unit. Amounts are minor units of it. Read with
* <code>subscription_id</code>, every amount counts only the credit that subscription can use.
*
* <p>Immutable: build one with {@link #builder()}, change a copy with {@link #toBuilder()}.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonAutoDetect(
getterVisibility = Visibility.NONE,
isGetterVisibility = Visibility.NONE,
setterVisibility = Visibility.NONE)
public final class Wallet {
@JsonProperty("as_of")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private JsonField<OffsetDateTime> asOf = JsonField.missing();
@JsonProperty("auto_top_up")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private JsonField<AutoTopUp> autoTopUp = JsonField.missing();
@JsonProperty("balance")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private JsonField<Long> balance = JsonField.missing();
@JsonProperty("credit_on_account")
private Long creditOnAccount;
@JsonProperty("credit_on_account_usage_only")
private Long creditOnAccountUsageOnly;
@JsonProperty("credit_unit")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private JsonField<String> creditUnit = JsonField.missing();
@JsonProperty("credit_unit_precision")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private JsonField<Integer> creditUnitPrecision = JsonField.missing();
@JsonProperty("currency")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private JsonField<Currency> currency = JsonField.missing();
@JsonProperty("low_balance_thresholds")
private List<Long> lowBalanceThresholds;
@JsonProperty("pauses_at_zero")
private Boolean pausesAtZero;
@JsonProperty("shared_balance")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private JsonField<Long> sharedBalance = JsonField.missing();
@JsonProperty("subscription_credit")
private List<SubscriptionCredit> subscriptionCredit;
@JsonProperty("unbilled_usage")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private JsonField<Long> unbilledUsage = JsonField.missing();
@JsonProperty("unit_price")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private JsonField<String> unitPrice = JsonField.missing();
@JsonProperty("unit_price_currency")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private JsonField<Currency> unitPriceCurrency = JsonField.missing();
@JsonProperty("upcoming_credit")
private Long upcomingCredit;
@JsonProperty("usage_at_zero")
private UsageAtZero usageAtZero;
private final Map<String, JsonNode> additionalProperties = new LinkedHashMap<>();
private Wallet() {}
private Wallet(Builder builder) {
this.asOf = builder.asOf;
this.autoTopUp = builder.autoTopUp;
this.balance = builder.balance;
this.creditOnAccount = builder.creditOnAccount;
this.creditOnAccountUsageOnly = builder.creditOnAccountUsageOnly;
this.creditUnit = builder.creditUnit;
this.creditUnitPrecision = builder.creditUnitPrecision;
this.currency = builder.currency;
this.lowBalanceThresholds = Utils.copyList(builder.lowBalanceThresholds);
this.pausesAtZero = builder.pausesAtZero;
this.sharedBalance = builder.sharedBalance;
this.subscriptionCredit = Utils.copyList(builder.subscriptionCredit);
this.unbilledUsage = builder.unbilledUsage;
this.unitPrice = builder.unitPrice;
this.unitPriceCurrency = builder.unitPriceCurrency;
this.upcomingCredit = builder.upcomingCredit;
this.usageAtZero = builder.usageAtZero;
this.additionalProperties.putAll(builder.additionalProperties);
}
/**
* A builder of {@code Wallet}.
*
* @return a new builder
*/
public static Builder builder() {
return new Builder();
}
/**
* A builder starting from this value.
*
* @return a new builder
*/
public Builder toBuilder() {
Builder builder = new Builder();
builder.asOf = asOf;
builder.autoTopUp = autoTopUp;
builder.balance = balance;
builder.creditOnAccount = creditOnAccount;
builder.creditOnAccountUsageOnly = creditOnAccountUsageOnly;
builder.creditUnit = creditUnit;
builder.creditUnitPrecision = creditUnitPrecision;
builder.currency = currency;
builder.lowBalanceThresholds = Utils.mutableList(lowBalanceThresholds);
builder.pausesAtZero = pausesAtZero;
builder.sharedBalance = sharedBalance;
builder.subscriptionCredit = Utils.mutableList(subscriptionCredit);
builder.unbilledUsage = unbilledUsage;
builder.unitPrice = unitPrice;
builder.unitPriceCurrency = unitPriceCurrency;
builder.upcomingCredit = upcomingCredit;
builder.usageAtZero = usageAtZero;
builder.additionalProperties.putAll(additionalProperties);
return builder;
}
/**
* When <code>balance</code> and <code>unbilled_usage</code> were computed. They follow usage
* within a few seconds while the balance is near zero or a threshold, and within a minute
* otherwise.
*
* @return the value, empty when unset or null
*/
public Optional<OffsetDateTime> asOf() {
return asOf.asOptional();
}
/**
* The {@code auto_top_up} property.
*
* @return the value, empty when unset or null
*/
public Optional<AutoTopUp> autoTopUp() {
return autoTopUp.asOptional();
}
/**
* What the customer has left: <code>credit_on_account</code> minus the part of <code>
* unbilled_usage</code> that credit will pay. Never negative: usage beyond the credit stays in
* <code>unbilled_usage</code>, to be invoiced. Low-balance alerts use it; automatic top-ups
* watch only its part that pays any charge (credit that belongs to no subscription and is not
* limited to usage or products). Absent, with <code>unbilled_usage</code> and <code>as_of
* </code>, until the customer's usage has been priced once. With <code>subscription_id</code>:
* the credit that subscription can spend once every subscription's unbilled usage is paid,
* minus its own unbilled usage no credit pays (negative then), as <code>GET /wallets/check
* </code> reads it. Credit restricted to products it is not charged for is left out. Credit
* that belongs to no subscription counts in the balance of every subscription that can use it
* (see <code>shared_balance</code>): never add subscriptions' balances up.
*
* @return the value, empty when unset or null
*/
public Optional<Long> balance() {
return balance.asOptional();
}
/**
* The ledger total: credit granted and effective, not yet applied to an invoice or expired,
* whatever it applies to. Usage not invoiced yet is not deducted (see <code>balance</code>).
*
* @return the value, never null
*/
public Long creditOnAccount() {
return Utils.required(creditOnAccount, "credit_on_account");
}
/**
* The part of <code>credit_on_account</code> that pays only usage charges.
*
* @return the value, never null
*/
public Long creditOnAccountUsageOnly() {
return Utils.required(creditOnAccountUsageOnly, "credit_on_account_usage_only");
}
/**
* The credit unit (its code) the wallet holds; absent for a currency.
*
* @return the value, empty when unset or null
*/
public Optional<String> creditUnit() {
return creditUnit.asOptional();
}
/**
* Decimal places of <code>credit_unit</code>: amounts are integers of 10^-precision credit.
*
* @return the value, empty when unset or null
*/
public Optional<Integer> creditUnitPrecision() {
return creditUnitPrecision.asOptional();
}
/**
* The {@code currency} property.
*
* @return the value, empty when unset or null
*/
public Optional<Currency> currency() {
return currency.asOptional();
}
/**
* Ascending, distinct, at most 5. <code>wallet.balance_low</code> fires once when <code>balance
* </code> falls below one; a drop below several at once fires once, for the lowest. All credit
* counts, including credit that belongs to a subscription or is limited to usage or products,
* which <code>wallet.depleted</code> leaves out: a wallet can be depleted without an alert
* firing.
*
* @return the value, never null
*/
public List<Long> lowBalanceThresholds() {
return Utils.required(lowBalanceThresholds, "low_balance_thresholds");
}
/**
* Usage stops as soon as the credit is used up, for at least one active subscription: by <code>
* usage_at_zero</code>, or by the plan of a subscription charging usage in this wallet.
*
* @return the value, never null
*/
public Boolean pausesAtZero() {
return Utils.required(pausesAtZero, "pauses_at_zero");
}
/**
* With <code>subscription_id</code> only: the part of <code>balance</code> that belongs to no
* subscription, which the customer's other subscriptions can spend too.
*
* @return the value, empty when unset or null
*/
public Optional<Long> sharedBalance() {
return sharedBalance.asOptional();
}
/**
* The part of <code>credit_on_account</code> that belongs to a subscription, which only that
* subscription's charges can use, per subscription. The rest pays any subscription.
*
* @return the value, never null
*/
public List<SubscriptionCredit> subscriptionCredit() {
return Utils.required(subscriptionCredit, "subscription_credit");
}
/**
* Usage recorded and priced but not invoiced yet, tax included, in minor units: what the next
* invoices will charge for it, paid from credit as far as the credit goes. With <code>
* subscription_id</code>, that subscription's usage only; other subscriptions' usage paid from
* shared credit still lowers <code>balance</code>.
*
* @return the value, empty when unset or null
*/
public Optional<Long> unbilledUsage() {
return unbilledUsage.asOptional();
}
/**
* Credit unit wallets: the price this customer agreed for one credit, in major units of <code>
* unit_price_currency</code>, as a decimal string (e.g. "0.0008"). Purchases and automatic
* top-ups in that currency charge it instead of the list price, unless a purchase sets its own
* <code>unit_price</code>. Absent: the list price applies.
*
* @return the value, empty when unset or null
*/
public Optional<String> unitPrice() {
return unitPrice.asOptional();
}
/**
* The {@code unit_price_currency} property.
*
* @return the value, empty when unset or null
*/
public Optional<Currency> unitPriceCurrency() {
return unitPriceCurrency.asOptional();
}
/**
* Credit granted that takes effect later.
*
* @return the value, never null
*/
public Long upcomingCredit() {
return Utils.required(upcomingCredit, "upcoming_credit");
}
/**
* What this customer's usage does once the credit a subscription can use for it is used up (its
* own credit, credit that belongs to no subscription, and credit limited to the product: the
* <code>balance</code> of <code>GET /wallets/check</code>). <code>FOLLOW_PLAN</code> applies
* the "when credit runs out" rule of each subscription's plan.
*
* @return the value, never null
*/
public UsageAtZero usageAtZero() {
return Utils.required(usageAtZero, "usage_at_zero");
}
/**
* Properties this version of the SDK does not know, kept as received and sent back.
*
* @return the properties by name, unmodifiable
*/
public Map<String, JsonNode> additionalProperties() {
return Collections.unmodifiableMap(additionalProperties);
}
@JsonAnyGetter
private Map<String, JsonNode> anyProperties() {
return additionalProperties;
}
@JsonAnySetter
private void putAnyProperty(String name, JsonNode value) {
additionalProperties.put(name, value);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Wallet that = (Wallet) o;
return Objects.equals(asOf, that.asOf)
&& Objects.equals(autoTopUp, that.autoTopUp)
&& Objects.equals(balance, that.balance)
&& Objects.equals(creditOnAccount, that.creditOnAccount)
&& Objects.equals(creditOnAccountUsageOnly, that.creditOnAccountUsageOnly)
&& Objects.equals(creditUnit, that.creditUnit)
&& Objects.equals(creditUnitPrecision, that.creditUnitPrecision)
&& Objects.equals(currency, that.currency)
&& Objects.equals(lowBalanceThresholds, that.lowBalanceThresholds)
&& Objects.equals(pausesAtZero, that.pausesAtZero)
&& Objects.equals(sharedBalance, that.sharedBalance)
&& Objects.equals(subscriptionCredit, that.subscriptionCredit)
&& Objects.equals(unbilledUsage, that.unbilledUsage)
&& Objects.equals(unitPrice, that.unitPrice)
&& Objects.equals(unitPriceCurrency, that.unitPriceCurrency)
&& Objects.equals(upcomingCredit, that.upcomingCredit)
&& Objects.equals(usageAtZero, that.usageAtZero)
&& Objects.equals(additionalProperties, that.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(
asOf,
autoTopUp,
balance,
creditOnAccount,
creditOnAccountUsageOnly,
creditUnit,
creditUnitPrecision,
currency,
lowBalanceThresholds,
pausesAtZero,
sharedBalance,
subscriptionCredit,
unbilledUsage,
unitPrice,
unitPriceCurrency,
upcomingCredit,
usageAtZero,
additionalProperties);
}
@Override
public String toString() {
return "Wallet{"
+ "asOf="
+ asOf
+ ", autoTopUp="
+ autoTopUp
+ ", balance="
+ balance
+ ", creditOnAccount="
+ creditOnAccount
+ ", creditOnAccountUsageOnly="
+ creditOnAccountUsageOnly
+ ", creditUnit="
+ creditUnit
+ ", creditUnitPrecision="
+ creditUnitPrecision
+ ", currency="
+ currency
+ ", lowBalanceThresholds="
+ lowBalanceThresholds
+ ", pausesAtZero="
+ pausesAtZero
+ ", sharedBalance="
+ sharedBalance
+ ", subscriptionCredit="
+ subscriptionCredit
+ ", unbilledUsage="
+ unbilledUsage
+ ", unitPrice="
+ unitPrice
+ ", unitPriceCurrency="
+ unitPriceCurrency
+ ", upcomingCredit="
+ upcomingCredit
+ ", usageAtZero="
+ usageAtZero
+ ", additionalProperties="
+ additionalProperties
+ "}";
}
/** Builds {@link Wallet}. */
public static final class Builder {
private JsonField<OffsetDateTime> asOf = JsonField.missing();
private JsonField<AutoTopUp> autoTopUp = JsonField.missing();
private JsonField<Long> balance = JsonField.missing();
private Long creditOnAccount;
private Long creditOnAccountUsageOnly;
private JsonField<String> creditUnit = JsonField.missing();
private JsonField<Integer> creditUnitPrecision = JsonField.missing();
private JsonField<Currency> currency = JsonField.missing();
private List<Long> lowBalanceThresholds;
private Boolean pausesAtZero;
private JsonField<Long> sharedBalance = JsonField.missing();
private List<SubscriptionCredit> subscriptionCredit;
private JsonField<Long> unbilledUsage = JsonField.missing();
private JsonField<String> unitPrice = JsonField.missing();
private JsonField<Currency> unitPriceCurrency = JsonField.missing();
private Long upcomingCredit;
private UsageAtZero usageAtZero;
private final Map<String, JsonNode> additionalProperties = new LinkedHashMap<>();
private Builder() {}
/**
* When <code>balance</code> and <code>unbilled_usage</code> were computed. They follow
* usage within a few seconds while the balance is near zero or a threshold, and within a
* minute otherwise.
*
* @param asOf the value, null to send an explicit {@code null}
* @return this builder
*/
public Builder asOf(OffsetDateTime asOf) {
this.asOf = JsonField.ofNullable(asOf);
return this;
}
/**
* The {@code auto_top_up} property.
*
* @param autoTopUp the value, null to send an explicit {@code null}
* @return this builder
*/
public Builder autoTopUp(AutoTopUp autoTopUp) {
this.autoTopUp = JsonField.ofNullable(autoTopUp);
return this;
}
/**
* What the customer has left: <code>credit_on_account</code> minus the part of <code>
* unbilled_usage</code> that credit will pay. Never negative: usage beyond the credit stays
* in <code>unbilled_usage</code>, to be invoiced. Low-balance alerts use it; automatic
* top-ups watch only its part that pays any charge (credit that belongs to no subscription
* and is not limited to usage or products). Absent, with <code>unbilled_usage</code> and
* <code>as_of</code>, until the customer's usage has been priced once. With <code>
* subscription_id</code>: the credit that subscription can spend once every subscription's
* unbilled usage is paid, minus its own unbilled usage no credit pays (negative then), as
* <code>GET /wallets/check</code> reads it. Credit restricted to products it is not charged
* for is left out. Credit that belongs to no subscription counts in the balance of every
* subscription that can use it (see <code>shared_balance</code>): never add subscriptions'
* balances up.
*
* @param balance the value, null to send an explicit {@code null}
* @return this builder
*/
public Builder balance(Long balance) {
this.balance = JsonField.ofNullable(balance);
return this;
}
/**
* The ledger total: credit granted and effective, not yet applied to an invoice or expired,
* whatever it applies to. Usage not invoiced yet is not deducted (see <code>balance</code>
* ).
*
* @param creditOnAccount the value
* @return this builder
*/
public Builder creditOnAccount(Long creditOnAccount) {
this.creditOnAccount = creditOnAccount;
return this;
}
/**
* The part of <code>credit_on_account</code> that pays only usage charges.
*
* @param creditOnAccountUsageOnly the value
* @return this builder
*/
public Builder creditOnAccountUsageOnly(Long creditOnAccountUsageOnly) {
this.creditOnAccountUsageOnly = creditOnAccountUsageOnly;
return this;
}
/**
* The credit unit (its code) the wallet holds; absent for a currency.
*
* @param creditUnit the value, null to send an explicit {@code null}
* @return this builder
*/
public Builder creditUnit(String creditUnit) {
this.creditUnit = JsonField.ofNullable(creditUnit);
return this;
}
/**
* Decimal places of <code>credit_unit</code>: amounts are integers of 10^-precision credit.
*
* @param creditUnitPrecision the value, null to send an explicit {@code null}
* @return this builder
*/
public Builder creditUnitPrecision(Integer creditUnitPrecision) {
this.creditUnitPrecision = JsonField.ofNullable(creditUnitPrecision);
return this;
}
/**
* The {@code currency} property.
*
* @param currency the value, null to send an explicit {@code null}
* @return this builder
*/
public Builder currency(Currency currency) {
this.currency = JsonField.ofNullable(currency);
return this;
}
/**
* Ascending, distinct, at most 5. <code>wallet.balance_low</code> fires once when <code>
* balance</code> falls below one; a drop below several at once fires once, for the lowest.
* All credit counts, including credit that belongs to a subscription or is limited to usage
* or products, which <code>wallet.depleted</code> leaves out: a wallet can be depleted
* without an alert firing.
*
* @param lowBalanceThresholds the value
* @return this builder
*/
public Builder lowBalanceThresholds(List<Long> lowBalanceThresholds) {
this.lowBalanceThresholds = Utils.mutableList(lowBalanceThresholds);
return this;
}
/**
* Adds an item to {@code low_balance_thresholds}.
*
* @param item the item
* @return this builder
*/
public Builder addLowBalanceThresholdsItem(Long item) {
if (this.lowBalanceThresholds == null) {
this.lowBalanceThresholds = new ArrayList<>();
}
this.lowBalanceThresholds.add(item);
return this;
}
/**
* Usage stops as soon as the credit is used up, for at least one active subscription: by
* <code>usage_at_zero</code>, or by the plan of a subscription charging usage in this
* wallet.
*
* @param pausesAtZero the value
* @return this builder
*/
public Builder pausesAtZero(Boolean pausesAtZero) {
this.pausesAtZero = pausesAtZero;
return this;
}
/**
* With <code>subscription_id</code> only: the part of <code>balance</code> that belongs to
* no subscription, which the customer's other subscriptions can spend too.
*
* @param sharedBalance the value, null to send an explicit {@code null}
* @return this builder
*/
public Builder sharedBalance(Long sharedBalance) {
this.sharedBalance = JsonField.ofNullable(sharedBalance);
return this;
}
/**
* The part of <code>credit_on_account</code> that belongs to a subscription, which only
* that subscription's charges can use, per subscription. The rest pays any subscription.
*
* @param subscriptionCredit the value
* @return this builder
*/
public Builder subscriptionCredit(List<SubscriptionCredit> subscriptionCredit) {
this.subscriptionCredit = Utils.mutableList(subscriptionCredit);
return this;
}
/**
* Adds an item to {@code subscription_credit}.
*
* @param item the item
* @return this builder
*/
public Builder addSubscriptionCreditItem(SubscriptionCredit item) {
if (this.subscriptionCredit == null) {
this.subscriptionCredit = new ArrayList<>();
}
this.subscriptionCredit.add(item);
return this;
}
/**
* Usage recorded and priced but not invoiced yet, tax included, in minor units: what the
* next invoices will charge for it, paid from credit as far as the credit goes. With <code>
* subscription_id</code>, that subscription's usage only; other subscriptions' usage paid
* from shared credit still lowers <code>balance</code>.
*
* @param unbilledUsage the value, null to send an explicit {@code null}
* @return this builder
*/
public Builder unbilledUsage(Long unbilledUsage) {
this.unbilledUsage = JsonField.ofNullable(unbilledUsage);
return this;
}
/**
* Credit unit wallets: the price this customer agreed for one credit, in major units of
* <code>unit_price_currency</code>, as a decimal string (e.g. "0.0008"). Purchases and
* automatic top-ups in that currency charge it instead of the list price, unless a purchase
* sets its own <code>unit_price</code>. Absent: the list price applies.
*
* @param unitPrice the value, null to send an explicit {@code null}
* @return this builder
*/
public Builder unitPrice(String unitPrice) {
this.unitPrice = JsonField.ofNullable(unitPrice);
return this;
}
/**
* The {@code unit_price_currency} property.
*
* @param unitPriceCurrency the value, null to send an explicit {@code null}
* @return this builder
*/
public Builder unitPriceCurrency(Currency unitPriceCurrency) {
this.unitPriceCurrency = JsonField.ofNullable(unitPriceCurrency);
return this;
}
/**
* Credit granted that takes effect later.
*
* @param upcomingCredit the value
* @return this builder
*/
public Builder upcomingCredit(Long upcomingCredit) {
this.upcomingCredit = upcomingCredit;
return this;
}
/**
* What this customer's usage does once the credit a subscription can use for it is used up
* (its own credit, credit that belongs to no subscription, and credit limited to the
* product: the <code>balance</code> of <code>GET /wallets/check</code>). <code>FOLLOW_PLAN
* </code> applies the "when credit runs out" rule of each subscription's plan.
*
* @param usageAtZero the value
* @return this builder
*/
public Builder usageAtZero(UsageAtZero usageAtZero) {
this.usageAtZero = usageAtZero;
return this;
}
/**
* A property the SDK does not know, sent along.
*
* @param name the property name
* @param value the JSON value
* @return this builder
*/
public Builder putAdditionalProperty(String name, JsonNode value) {
additionalProperties.put(name, value);
return this;
}
/**
* Properties the SDK does not know, sent along.
*
* @param additionalProperties the properties by name
* @return this builder
*/
public Builder putAllAdditionalProperties(Map<String, JsonNode> additionalProperties) {
this.additionalProperties.putAll(additionalProperties);
return this;
}
/**
* Leaves out a property the SDK does not know.
*
* @param name the property name
* @return this builder
*/
public Builder removeAdditionalProperty(String name) {
additionalProperties.remove(name);
return this;
}
/**
* The {@code Wallet}.
*
* @return the immutable value
* @throws IllegalStateException when a required property is not set
*/
public Wallet build() {
Utils.checkRequired(creditOnAccount, "credit_on_account");
Utils.checkRequired(creditOnAccountUsageOnly, "credit_on_account_usage_only");
Utils.checkRequired(lowBalanceThresholds, "low_balance_thresholds");
Utils.checkRequired(pausesAtZero, "pauses_at_zero");
Utils.checkRequired(subscriptionCredit, "subscription_credit");
Utils.checkRequired(upcomingCredit, "upcoming_credit");
Utils.checkRequired(usageAtZero, "usage_at_zero");
return new Wallet(this);
}
}
/**
* Parse {@code json} as {@code Wallet}.
*
* @param json the JSON text
* @return the value
* @throws com.meteroid.exceptions.InvalidDataException if it is not valid JSON of this shape
*/
public static Wallet fromJson(String json) {
return Utils.parse(json, Wallet.class);
}
/**
* This value as JSON.
*
* @return the JSON text
*/
public String toJson() {
return Utils.json(this);
}
}