|
| 1 | +part of '../../messages.dart'; |
| 2 | + |
| 3 | +enum _CreditGrantObject { |
| 4 | + @JsonValue('billing.credit_grant') |
| 5 | + billingCreditGrant, |
| 6 | +} |
| 7 | + |
| 8 | +/// https://docs.stripe.com/api/billing/credit-grant/object |
| 9 | +@JsonSerializable() |
| 10 | +class CreditGrant extends Message { |
| 11 | + final _CreditGrantObject object; |
| 12 | + |
| 13 | + /// Unique identifier for the object. |
| 14 | + final String id; |
| 15 | + |
| 16 | + /// Amount of this credit grant. |
| 17 | + final CreditGrantAmount amount; |
| 18 | + |
| 19 | + /// Configuration specifying what this credit grant applies to. We currently |
| 20 | + /// only support metered prices that have a Billing Meter attached to them. |
| 21 | + final CreditGrantApplicabilityConfig applicabilityConfig; |
| 22 | + |
| 23 | + /// he category of this credit grant. This is for tracking purposes and isn’t |
| 24 | + /// displayed to the customer. |
| 25 | + final CreditGrantCategory category; |
| 26 | + |
| 27 | + /// Time at which the object was created. Measured in seconds since the Unix |
| 28 | + /// epoch. |
| 29 | + final int created; |
| 30 | + |
| 31 | + /// ID of the customer receiving the billing credits. |
| 32 | + final String customer; |
| 33 | + |
| 34 | + /// Has the value true if the object exists in live mode or the value false |
| 35 | + /// if the object exists in test mode. |
| 36 | + final bool livemode; |
| 37 | + |
| 38 | + /// Time at which the object was last updated. Measured in seconds since the |
| 39 | + /// Unix epoch. |
| 40 | + final int updated; |
| 41 | + |
| 42 | + /// The time when the billing credits become effective-when they’re eligible |
| 43 | + /// for use. |
| 44 | + final int? effectiveAt; |
| 45 | + |
| 46 | + /// The time when the billing credits expire. If not present, the billing |
| 47 | + /// credits don’t expire. |
| 48 | + final int? expiresAt; |
| 49 | + |
| 50 | + /// Set of key-value pairs that you can attach to an object. This can be |
| 51 | + /// useful for storing additional information about the object in a structured |
| 52 | + /// format. |
| 53 | + final Map<String, dynamic>? metadata; |
| 54 | + |
| 55 | + /// A descriptive name shown in dashboard. |
| 56 | + final String? name; |
| 57 | + |
| 58 | + /// The time when this credit grant was voided. If not present, the credit |
| 59 | + /// grant hasn’t been voided. |
| 60 | + final int? voidedAt; |
| 61 | + |
| 62 | + CreditGrant({ |
| 63 | + required this.object, |
| 64 | + required this.id, |
| 65 | + required this.amount, |
| 66 | + required this.applicabilityConfig, |
| 67 | + required this.category, |
| 68 | + required this.created, |
| 69 | + required this.customer, |
| 70 | + required this.livemode, |
| 71 | + required this.updated, |
| 72 | + this.effectiveAt, |
| 73 | + this.expiresAt, |
| 74 | + this.metadata, |
| 75 | + this.name, |
| 76 | + this.voidedAt, |
| 77 | + }); |
| 78 | + |
| 79 | + factory CreditGrant.fromJson(Map<String, dynamic> json) => |
| 80 | + _$CreditGrantFromJson(json); |
| 81 | + |
| 82 | + @override |
| 83 | + Map<String, dynamic> toJson() => _$CreditGrantToJson(this); |
| 84 | +} |
| 85 | + |
| 86 | +/// https://docs.stripe.com/api/billing/credit-grant/object#billing_credit_grant_object-amount |
| 87 | +@JsonSerializable() |
| 88 | +class CreditGrantAmount { |
| 89 | + /// The monetary amount. |
| 90 | + final CreditGrantAmountMonetary? monetary; |
| 91 | + |
| 92 | + /// The type of this amount. We currently only support monetary billing |
| 93 | + /// credits. |
| 94 | + final CreditGrantAmountType type; |
| 95 | + |
| 96 | + CreditGrantAmount({ |
| 97 | + |
| 98 | + required this.type, |
| 99 | + this.monetary, |
| 100 | + }); |
| 101 | + |
| 102 | + factory CreditGrantAmount.fromJson(Map<String, dynamic> json) => |
| 103 | + _$CreditGrantAmountFromJson(json); |
| 104 | + |
| 105 | + Map<String, dynamic> toJson() => _$CreditGrantAmountToJson(this); |
| 106 | +} |
| 107 | + |
| 108 | +/// https://docs.stripe.com/api/billing/credit-grant/object#billing_credit_grant_object-amount-monetary |
| 109 | +@JsonSerializable() |
| 110 | +class CreditGrantAmountMonetary { |
| 111 | + /// Three-letter ISO currency code, in lowercase. Must be a supported |
| 112 | + /// currency. |
| 113 | + final String currency; |
| 114 | + |
| 115 | + /// A positive integer representing the amount. |
| 116 | + final int value; |
| 117 | + |
| 118 | + CreditGrantAmountMonetary({ |
| 119 | + required this.currency, |
| 120 | + required this.value, |
| 121 | + }); |
| 122 | + |
| 123 | + factory CreditGrantAmountMonetary.fromJson(Map<String, dynamic> json) => |
| 124 | + _$CreditGrantAmountMonetaryFromJson(json); |
| 125 | + |
| 126 | + Map<String, dynamic> toJson() => _$CreditGrantAmountMonetaryToJson(this); |
| 127 | +} |
| 128 | + |
| 129 | +/// https://docs.stripe.com/api/billing/credit-grant/object#billing_credit_grant_object-amount-type |
| 130 | +enum CreditGrantAmountType { |
| 131 | + /// The amount is a monetary amount. |
| 132 | + monetary, |
| 133 | +} |
| 134 | + |
| 135 | +/// https://docs.stripe.com/api/billing/credit-grant/object#billing_credit_grant_object-applicability_config |
| 136 | +@JsonSerializable() |
| 137 | +class CreditGrantApplicabilityConfig { |
| 138 | + /// Specify the scope of this applicability config. |
| 139 | + final CreditGrantApplicabilityConfigScope scope; |
| 140 | + |
| 141 | + CreditGrantApplicabilityConfig({ |
| 142 | + required this.scope, |
| 143 | + }); |
| 144 | + |
| 145 | + factory CreditGrantApplicabilityConfig.fromJson(Map<String, dynamic> json) => |
| 146 | + _$CreditGrantApplicabilityConfigFromJson(json); |
| 147 | + |
| 148 | + Map<String, dynamic> toJson() => _$CreditGrantApplicabilityConfigToJson(this); |
| 149 | +} |
| 150 | + |
| 151 | +/// https://docs.stripe.com/api/billing/credit-grant/object#billing_credit_grant_object-applicability_config-scope |
| 152 | +@JsonSerializable() |
| 153 | +class CreditGrantApplicabilityConfigScope { |
| 154 | + /// The price type that credit grants can apply to. We currently only support |
| 155 | + /// the metered price type. This refers to prices that have a Billing Meter |
| 156 | + /// attached to them. Cannot be used in combination with prices. |
| 157 | + final CreditGrantApplicabilityConfigScopePriceType? priceType; |
| 158 | + |
| 159 | + CreditGrantApplicabilityConfigScope({ |
| 160 | + this.priceType, |
| 161 | + }); |
| 162 | + |
| 163 | + factory CreditGrantApplicabilityConfigScope.fromJson( |
| 164 | + Map<String, dynamic> json) => |
| 165 | + _$CreditGrantApplicabilityConfigScopeFromJson(json); |
| 166 | + |
| 167 | + Map<String, dynamic> toJson() => |
| 168 | + _$CreditGrantApplicabilityConfigScopeToJson(this); |
| 169 | +} |
| 170 | + |
| 171 | +/// https://docs.stripe.com/api/billing/credit-grant/object#billing_credit_grant_object-applicability_config-scope-price_type |
| 172 | +enum CreditGrantApplicabilityConfigScopePriceType { |
| 173 | + /// Credit grants being created can only apply to metered prices. |
| 174 | + metered, |
| 175 | +} |
| 176 | + |
| 177 | +/// https://docs.stripe.com/api/billing/credit-grant/object#billing_credit_grant_object-category |
| 178 | +enum CreditGrantCategory { |
| 179 | + /// The credit grant was purchased by the customer for some amount. |
| 180 | + paid, |
| 181 | + |
| 182 | + /// The credit grant was given to the customer for free. |
| 183 | + promotional, |
| 184 | +} |
0 commit comments