Skip to content

Commit f1b9c1c

Browse files
feat(api): gift cards (#125)
1 parent 09af66e commit f1b9c1c

26 files changed

+1833
-59
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 35
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/terminal%2Fterminal-979a6c40552c45a380d71f0b47e8d6732104f6aed4a2854e1f3952a9dd24ae65.yml
1+
configured_endpoints: 37
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/terminal%2Fterminal-3b68749c34dcc398f771ae304585f9e58e14b68ddf000f75366ee42eb1079121.yml

terminal-java-core/src/main/kotlin/shop/terminal/api/models/cart/Cart.kt

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ private constructor(
3838
@JsonProperty("cardID")
3939
@ExcludeMissing
4040
private val cardId: JsonField<String> = JsonMissing.of(),
41+
@JsonProperty("giftCardID")
42+
@ExcludeMissing
43+
private val giftCardId: JsonField<String> = JsonMissing.of(),
4144
@JsonProperty("shipping")
4245
@ExcludeMissing
4346
private val shipping: JsonField<Shipping> = JsonMissing.of(),
@@ -59,6 +62,9 @@ private constructor(
5962
/** ID of the card selected on the current user's cart. */
6063
fun cardId(): Optional<String> = Optional.ofNullable(cardId.getNullable("cardID"))
6164

65+
/** ID of the gift card applied to the current user's cart. */
66+
fun giftCardId(): Optional<String> = Optional.ofNullable(giftCardId.getNullable("giftCardID"))
67+
6268
/** Shipping information for the current user's cart. */
6369
fun shipping(): Optional<Shipping> = Optional.ofNullable(shipping.getNullable("shipping"))
6470

@@ -77,6 +83,9 @@ private constructor(
7783
/** ID of the card selected on the current user's cart. */
7884
@JsonProperty("cardID") @ExcludeMissing fun _cardId(): JsonField<String> = cardId
7985

86+
/** ID of the gift card applied to the current user's cart. */
87+
@JsonProperty("giftCardID") @ExcludeMissing fun _giftCardId(): JsonField<String> = giftCardId
88+
8089
/** Shipping information for the current user's cart. */
8190
@JsonProperty("shipping") @ExcludeMissing fun _shipping(): JsonField<Shipping> = shipping
8291

@@ -96,6 +105,7 @@ private constructor(
96105
subtotal()
97106
addressId()
98107
cardId()
108+
giftCardId()
99109
shipping().ifPresent { it.validate() }
100110
validated = true
101111
}
@@ -125,6 +135,7 @@ private constructor(
125135
private var subtotal: JsonField<Long>? = null
126136
private var addressId: JsonField<String> = JsonMissing.of()
127137
private var cardId: JsonField<String> = JsonMissing.of()
138+
private var giftCardId: JsonField<String> = JsonMissing.of()
128139
private var shipping: JsonField<Shipping> = JsonMissing.of()
129140
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
130141

@@ -135,6 +146,7 @@ private constructor(
135146
subtotal = cart.subtotal
136147
addressId = cart.addressId
137148
cardId = cart.cardId
149+
giftCardId = cart.giftCardId
138150
shipping = cart.shipping
139151
additionalProperties = cart.additionalProperties.toMutableMap()
140152
}
@@ -177,6 +189,12 @@ private constructor(
177189
/** ID of the card selected on the current user's cart. */
178190
fun cardId(cardId: JsonField<String>) = apply { this.cardId = cardId }
179191

192+
/** ID of the gift card applied to the current user's cart. */
193+
fun giftCardId(giftCardId: String) = giftCardId(JsonField.of(giftCardId))
194+
195+
/** ID of the gift card applied to the current user's cart. */
196+
fun giftCardId(giftCardId: JsonField<String>) = apply { this.giftCardId = giftCardId }
197+
180198
/** Shipping information for the current user's cart. */
181199
fun shipping(shipping: Shipping) = shipping(JsonField.of(shipping))
182200

@@ -209,6 +227,7 @@ private constructor(
209227
checkRequired("subtotal", subtotal),
210228
addressId,
211229
cardId,
230+
giftCardId,
212231
shipping,
213232
additionalProperties.toImmutable(),
214233
)
@@ -222,25 +241,43 @@ private constructor(
222241
@JsonProperty("subtotal")
223242
@ExcludeMissing
224243
private val subtotal: JsonField<Long> = JsonMissing.of(),
244+
@JsonProperty("giftCard")
245+
@ExcludeMissing
246+
private val giftCard: JsonField<Long> = JsonMissing.of(),
225247
@JsonProperty("shipping")
226248
@ExcludeMissing
227249
private val shipping: JsonField<Long> = JsonMissing.of(),
250+
@JsonProperty("total")
251+
@ExcludeMissing
252+
private val total: JsonField<Long> = JsonMissing.of(),
228253
@JsonAnySetter
229254
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
230255
) {
231256

232257
/** Subtotal of the current user's cart, in cents (USD). */
233258
fun subtotal(): Long = subtotal.getRequired("subtotal")
234259

260+
/** Amount applied from gift card on the current user's cart, in cents (USD). */
261+
fun giftCard(): Optional<Long> = Optional.ofNullable(giftCard.getNullable("giftCard"))
262+
235263
/** Shipping amount of the current user's cart, in cents (USD). */
236264
fun shipping(): Optional<Long> = Optional.ofNullable(shipping.getNullable("shipping"))
237265

266+
/** Total amount after gift card applied, in cents (USD). */
267+
fun total(): Optional<Long> = Optional.ofNullable(total.getNullable("total"))
268+
238269
/** Subtotal of the current user's cart, in cents (USD). */
239270
@JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField<Long> = subtotal
240271

272+
/** Amount applied from gift card on the current user's cart, in cents (USD). */
273+
@JsonProperty("giftCard") @ExcludeMissing fun _giftCard(): JsonField<Long> = giftCard
274+
241275
/** Shipping amount of the current user's cart, in cents (USD). */
242276
@JsonProperty("shipping") @ExcludeMissing fun _shipping(): JsonField<Long> = shipping
243277

278+
/** Total amount after gift card applied, in cents (USD). */
279+
@JsonProperty("total") @ExcludeMissing fun _total(): JsonField<Long> = total
280+
244281
@JsonAnyGetter
245282
@ExcludeMissing
246283
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
@@ -253,7 +290,9 @@ private constructor(
253290
}
254291

255292
subtotal()
293+
giftCard()
256294
shipping()
295+
total()
257296
validated = true
258297
}
259298

@@ -276,13 +315,17 @@ private constructor(
276315
class Builder internal constructor() {
277316

278317
private var subtotal: JsonField<Long>? = null
318+
private var giftCard: JsonField<Long> = JsonMissing.of()
279319
private var shipping: JsonField<Long> = JsonMissing.of()
320+
private var total: JsonField<Long> = JsonMissing.of()
280321
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
281322

282323
@JvmSynthetic
283324
internal fun from(amount: Amount) = apply {
284325
subtotal = amount.subtotal
326+
giftCard = amount.giftCard
285327
shipping = amount.shipping
328+
total = amount.total
286329
additionalProperties = amount.additionalProperties.toMutableMap()
287330
}
288331

@@ -292,12 +335,24 @@ private constructor(
292335
/** Subtotal of the current user's cart, in cents (USD). */
293336
fun subtotal(subtotal: JsonField<Long>) = apply { this.subtotal = subtotal }
294337

338+
/** Amount applied from gift card on the current user's cart, in cents (USD). */
339+
fun giftCard(giftCard: Long) = giftCard(JsonField.of(giftCard))
340+
341+
/** Amount applied from gift card on the current user's cart, in cents (USD). */
342+
fun giftCard(giftCard: JsonField<Long>) = apply { this.giftCard = giftCard }
343+
295344
/** Shipping amount of the current user's cart, in cents (USD). */
296345
fun shipping(shipping: Long) = shipping(JsonField.of(shipping))
297346

298347
/** Shipping amount of the current user's cart, in cents (USD). */
299348
fun shipping(shipping: JsonField<Long>) = apply { this.shipping = shipping }
300349

350+
/** Total amount after gift card applied, in cents (USD). */
351+
fun total(total: Long) = total(JsonField.of(total))
352+
353+
/** Total amount after gift card applied, in cents (USD). */
354+
fun total(total: JsonField<Long>) = apply { this.total = total }
355+
301356
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
302357
this.additionalProperties.clear()
303358
putAllAdditionalProperties(additionalProperties)
@@ -320,7 +375,9 @@ private constructor(
320375
fun build(): Amount =
321376
Amount(
322377
checkRequired("subtotal", subtotal),
378+
giftCard,
323379
shipping,
380+
total,
324381
additionalProperties.toImmutable(),
325382
)
326383
}
@@ -330,17 +387,17 @@ private constructor(
330387
return true
331388
}
332389

333-
return /* spotless:off */ other is Amount && subtotal == other.subtotal && shipping == other.shipping && additionalProperties == other.additionalProperties /* spotless:on */
390+
return /* spotless:off */ other is Amount && subtotal == other.subtotal && giftCard == other.giftCard && shipping == other.shipping && total == other.total && additionalProperties == other.additionalProperties /* spotless:on */
334391
}
335392

336393
/* spotless:off */
337-
private val hashCode: Int by lazy { Objects.hash(subtotal, shipping, additionalProperties) }
394+
private val hashCode: Int by lazy { Objects.hash(subtotal, giftCard, shipping, total, additionalProperties) }
338395
/* spotless:on */
339396

340397
override fun hashCode(): Int = hashCode
341398

342399
override fun toString() =
343-
"Amount{subtotal=$subtotal, shipping=$shipping, additionalProperties=$additionalProperties}"
400+
"Amount{subtotal=$subtotal, giftCard=$giftCard, shipping=$shipping, total=$total, additionalProperties=$additionalProperties}"
344401
}
345402

346403
/** An item in the current Terminal shop user's cart. */
@@ -638,15 +695,15 @@ private constructor(
638695
return true
639696
}
640697

641-
return /* spotless:off */ other is Cart && amount == other.amount && items == other.items && subtotal == other.subtotal && addressId == other.addressId && cardId == other.cardId && shipping == other.shipping && additionalProperties == other.additionalProperties /* spotless:on */
698+
return /* spotless:off */ other is Cart && amount == other.amount && items == other.items && subtotal == other.subtotal && addressId == other.addressId && cardId == other.cardId && giftCardId == other.giftCardId && shipping == other.shipping && additionalProperties == other.additionalProperties /* spotless:on */
642699
}
643700

644701
/* spotless:off */
645-
private val hashCode: Int by lazy { Objects.hash(amount, items, subtotal, addressId, cardId, shipping, additionalProperties) }
702+
private val hashCode: Int by lazy { Objects.hash(amount, items, subtotal, addressId, cardId, giftCardId, shipping, additionalProperties) }
646703
/* spotless:on */
647704

648705
override fun hashCode(): Int = hashCode
649706

650707
override fun toString() =
651-
"Cart{amount=$amount, items=$items, subtotal=$subtotal, addressId=$addressId, cardId=$cardId, shipping=$shipping, additionalProperties=$additionalProperties}"
708+
"Cart{amount=$amount, items=$items, subtotal=$subtotal, addressId=$addressId, cardId=$cardId, giftCardId=$giftCardId, shipping=$shipping, additionalProperties=$additionalProperties}"
652709
}

0 commit comments

Comments
 (0)