|
| 1 | +package com.stripe.param; |
| 2 | + |
| 3 | +import com.google.gson.annotations.SerializedName; |
| 4 | +import com.stripe.net.ApiRequestParams; |
| 5 | +import java.util.ArrayList; |
| 6 | +import java.util.HashMap; |
| 7 | +import java.util.List; |
| 8 | +import java.util.Map; |
| 9 | +import lombok.Getter; |
| 10 | + |
| 11 | +@Getter |
| 12 | +public class CreditNotePreviewParams extends ApiRequestParams { |
| 13 | + /** The integer amount in **%s** representing the total amount of the credit note. */ |
| 14 | + @SerializedName("amount") |
| 15 | + Long amount; |
| 16 | + |
| 17 | + /** |
| 18 | + * The integer amount in **%s** representing the amount to credit the customer's balance, which |
| 19 | + * will be automatically applied to their next invoice. |
| 20 | + */ |
| 21 | + @SerializedName("credit_amount") |
| 22 | + Long creditAmount; |
| 23 | + |
| 24 | + /** Specifies which fields in the response should be expanded. */ |
| 25 | + @SerializedName("expand") |
| 26 | + List<String> expand; |
| 27 | + |
| 28 | + /** |
| 29 | + * Map of extra parameters for custom features not available in this client library. The content |
| 30 | + * in this map is not serialized under this field's {@code @SerializedName} value. Instead, each |
| 31 | + * key/value pair is serialized as if the key is a root-level field (serialized) name in this |
| 32 | + * param object. Effectively, this map is flattened to its parent instance. |
| 33 | + */ |
| 34 | + @SerializedName(ApiRequestParams.EXTRA_PARAMS_KEY) |
| 35 | + Map<String, Object> extraParams; |
| 36 | + |
| 37 | + /** ID of the invoice. */ |
| 38 | + @SerializedName("invoice") |
| 39 | + String invoice; |
| 40 | + |
| 41 | + /** The credit note's memo appears on the credit note PDF. */ |
| 42 | + @SerializedName("memo") |
| 43 | + String memo; |
| 44 | + |
| 45 | + /** |
| 46 | + * Set of key-value pairs that you can attach to an object. This can be useful for storing |
| 47 | + * additional information about the object in a structured format. Individual keys can be unset by |
| 48 | + * posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. |
| 49 | + */ |
| 50 | + @SerializedName("metadata") |
| 51 | + Map<String, String> metadata; |
| 52 | + |
| 53 | + /** The integer amount in **%s** representing the amount that is credited outside of Stripe. */ |
| 54 | + @SerializedName("out_of_band_amount") |
| 55 | + Long outOfBandAmount; |
| 56 | + |
| 57 | + /** |
| 58 | + * Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or |
| 59 | + * `product_unsatisfactory`. |
| 60 | + */ |
| 61 | + @SerializedName("reason") |
| 62 | + Reason reason; |
| 63 | + |
| 64 | + /** ID of an existing refund to link this credit note to. */ |
| 65 | + @SerializedName("refund") |
| 66 | + String refund; |
| 67 | + |
| 68 | + /** |
| 69 | + * The integer amount in **%s** representing the amount to refund. If set, a refund will be |
| 70 | + * created for the charge associated with the invoice. |
| 71 | + */ |
| 72 | + @SerializedName("refund_amount") |
| 73 | + Long refundAmount; |
| 74 | + |
| 75 | + private CreditNotePreviewParams( |
| 76 | + Long amount, |
| 77 | + Long creditAmount, |
| 78 | + List<String> expand, |
| 79 | + Map<String, Object> extraParams, |
| 80 | + String invoice, |
| 81 | + String memo, |
| 82 | + Map<String, String> metadata, |
| 83 | + Long outOfBandAmount, |
| 84 | + Reason reason, |
| 85 | + String refund, |
| 86 | + Long refundAmount) { |
| 87 | + this.amount = amount; |
| 88 | + this.creditAmount = creditAmount; |
| 89 | + this.expand = expand; |
| 90 | + this.extraParams = extraParams; |
| 91 | + this.invoice = invoice; |
| 92 | + this.memo = memo; |
| 93 | + this.metadata = metadata; |
| 94 | + this.outOfBandAmount = outOfBandAmount; |
| 95 | + this.reason = reason; |
| 96 | + this.refund = refund; |
| 97 | + this.refundAmount = refundAmount; |
| 98 | + } |
| 99 | + |
| 100 | + public static Builder builder() { |
| 101 | + return new Builder(); |
| 102 | + } |
| 103 | + |
| 104 | + public static class Builder { |
| 105 | + private Long amount; |
| 106 | + |
| 107 | + private Long creditAmount; |
| 108 | + |
| 109 | + private List<String> expand; |
| 110 | + |
| 111 | + private Map<String, Object> extraParams; |
| 112 | + |
| 113 | + private String invoice; |
| 114 | + |
| 115 | + private String memo; |
| 116 | + |
| 117 | + private Map<String, String> metadata; |
| 118 | + |
| 119 | + private Long outOfBandAmount; |
| 120 | + |
| 121 | + private Reason reason; |
| 122 | + |
| 123 | + private String refund; |
| 124 | + |
| 125 | + private Long refundAmount; |
| 126 | + |
| 127 | + /** Finalize and obtain parameter instance from this builder. */ |
| 128 | + public CreditNotePreviewParams build() { |
| 129 | + return new CreditNotePreviewParams( |
| 130 | + this.amount, |
| 131 | + this.creditAmount, |
| 132 | + this.expand, |
| 133 | + this.extraParams, |
| 134 | + this.invoice, |
| 135 | + this.memo, |
| 136 | + this.metadata, |
| 137 | + this.outOfBandAmount, |
| 138 | + this.reason, |
| 139 | + this.refund, |
| 140 | + this.refundAmount); |
| 141 | + } |
| 142 | + |
| 143 | + /** The integer amount in **%s** representing the total amount of the credit note. */ |
| 144 | + public Builder setAmount(Long amount) { |
| 145 | + this.amount = amount; |
| 146 | + return this; |
| 147 | + } |
| 148 | + |
| 149 | + /** |
| 150 | + * The integer amount in **%s** representing the amount to credit the customer's balance, which |
| 151 | + * will be automatically applied to their next invoice. |
| 152 | + */ |
| 153 | + public Builder setCreditAmount(Long creditAmount) { |
| 154 | + this.creditAmount = creditAmount; |
| 155 | + return this; |
| 156 | + } |
| 157 | + |
| 158 | + /** |
| 159 | + * Add an element to `expand` list. A list is initialized for the first `add/addAll` call, and |
| 160 | + * subsequent calls adds additional elements to the original list. See {@link |
| 161 | + * CreditNotePreviewParams#expand} for the field documentation. |
| 162 | + */ |
| 163 | + public Builder addExpand(String element) { |
| 164 | + if (this.expand == null) { |
| 165 | + this.expand = new ArrayList<>(); |
| 166 | + } |
| 167 | + this.expand.add(element); |
| 168 | + return this; |
| 169 | + } |
| 170 | + |
| 171 | + /** |
| 172 | + * Add all elements to `expand` list. A list is initialized for the first `add/addAll` call, and |
| 173 | + * subsequent calls adds additional elements to the original list. See {@link |
| 174 | + * CreditNotePreviewParams#expand} for the field documentation. |
| 175 | + */ |
| 176 | + public Builder addAllExpand(List<String> elements) { |
| 177 | + if (this.expand == null) { |
| 178 | + this.expand = new ArrayList<>(); |
| 179 | + } |
| 180 | + this.expand.addAll(elements); |
| 181 | + return this; |
| 182 | + } |
| 183 | + |
| 184 | + /** |
| 185 | + * Add a key/value pair to `extraParams` map. A map is initialized for the first `put/putAll` |
| 186 | + * call, and subsequent calls add additional key/value pairs to the original map. See {@link |
| 187 | + * CreditNotePreviewParams#extraParams} for the field documentation. |
| 188 | + */ |
| 189 | + public Builder putExtraParam(String key, Object value) { |
| 190 | + if (this.extraParams == null) { |
| 191 | + this.extraParams = new HashMap<>(); |
| 192 | + } |
| 193 | + this.extraParams.put(key, value); |
| 194 | + return this; |
| 195 | + } |
| 196 | + |
| 197 | + /** |
| 198 | + * Add all map key/value pairs to `extraParams` map. A map is initialized for the first |
| 199 | + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original map. |
| 200 | + * See {@link CreditNotePreviewParams#extraParams} for the field documentation. |
| 201 | + */ |
| 202 | + public Builder putAllExtraParam(Map<String, Object> map) { |
| 203 | + if (this.extraParams == null) { |
| 204 | + this.extraParams = new HashMap<>(); |
| 205 | + } |
| 206 | + this.extraParams.putAll(map); |
| 207 | + return this; |
| 208 | + } |
| 209 | + |
| 210 | + /** ID of the invoice. */ |
| 211 | + public Builder setInvoice(String invoice) { |
| 212 | + this.invoice = invoice; |
| 213 | + return this; |
| 214 | + } |
| 215 | + |
| 216 | + /** The credit note's memo appears on the credit note PDF. */ |
| 217 | + public Builder setMemo(String memo) { |
| 218 | + this.memo = memo; |
| 219 | + return this; |
| 220 | + } |
| 221 | + |
| 222 | + /** |
| 223 | + * Add a key/value pair to `metadata` map. A map is initialized for the first `put/putAll` call, |
| 224 | + * and subsequent calls add additional key/value pairs to the original map. See {@link |
| 225 | + * CreditNotePreviewParams#metadata} for the field documentation. |
| 226 | + */ |
| 227 | + public Builder putMetadata(String key, String value) { |
| 228 | + if (this.metadata == null) { |
| 229 | + this.metadata = new HashMap<>(); |
| 230 | + } |
| 231 | + this.metadata.put(key, value); |
| 232 | + return this; |
| 233 | + } |
| 234 | + |
| 235 | + /** |
| 236 | + * Add all map key/value pairs to `metadata` map. A map is initialized for the first |
| 237 | + * `put/putAll` call, and subsequent calls add additional key/value pairs to the original map. |
| 238 | + * See {@link CreditNotePreviewParams#metadata} for the field documentation. |
| 239 | + */ |
| 240 | + public Builder putAllMetadata(Map<String, String> map) { |
| 241 | + if (this.metadata == null) { |
| 242 | + this.metadata = new HashMap<>(); |
| 243 | + } |
| 244 | + this.metadata.putAll(map); |
| 245 | + return this; |
| 246 | + } |
| 247 | + |
| 248 | + /** The integer amount in **%s** representing the amount that is credited outside of Stripe. */ |
| 249 | + public Builder setOutOfBandAmount(Long outOfBandAmount) { |
| 250 | + this.outOfBandAmount = outOfBandAmount; |
| 251 | + return this; |
| 252 | + } |
| 253 | + |
| 254 | + /** |
| 255 | + * Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or |
| 256 | + * `product_unsatisfactory`. |
| 257 | + */ |
| 258 | + public Builder setReason(Reason reason) { |
| 259 | + this.reason = reason; |
| 260 | + return this; |
| 261 | + } |
| 262 | + |
| 263 | + /** ID of an existing refund to link this credit note to. */ |
| 264 | + public Builder setRefund(String refund) { |
| 265 | + this.refund = refund; |
| 266 | + return this; |
| 267 | + } |
| 268 | + |
| 269 | + /** |
| 270 | + * The integer amount in **%s** representing the amount to refund. If set, a refund will be |
| 271 | + * created for the charge associated with the invoice. |
| 272 | + */ |
| 273 | + public Builder setRefundAmount(Long refundAmount) { |
| 274 | + this.refundAmount = refundAmount; |
| 275 | + return this; |
| 276 | + } |
| 277 | + } |
| 278 | + |
| 279 | + public enum Reason implements ApiRequestParams.EnumParam { |
| 280 | + @SerializedName("duplicate") |
| 281 | + DUPLICATE("duplicate"), |
| 282 | + |
| 283 | + @SerializedName("fraudulent") |
| 284 | + FRAUDULENT("fraudulent"), |
| 285 | + |
| 286 | + @SerializedName("order_change") |
| 287 | + ORDER_CHANGE("order_change"), |
| 288 | + |
| 289 | + @SerializedName("product_unsatisfactory") |
| 290 | + PRODUCT_UNSATISFACTORY("product_unsatisfactory"); |
| 291 | + |
| 292 | + @Getter(onMethod_ = {@Override}) |
| 293 | + private final String value; |
| 294 | + |
| 295 | + Reason(String value) { |
| 296 | + this.value = value; |
| 297 | + } |
| 298 | + } |
| 299 | +} |
0 commit comments