@@ -4,15 +4,14 @@ import com.google.gson.Gson
44import com.google.gson.JsonObject
55import com.google.gson.annotations.SerializedName
66import com.google.gson.reflect.TypeToken
7- import io.snabble.sdk.payment.PaymentCredentials
8- import io.snabble.sdk.Product
9- import io.snabble.sdk.coupons.Coupon
107import io.snabble.sdk.FulfillmentState
118import io.snabble.sdk.PaymentMethod
9+ import io.snabble.sdk.Product
10+ import io.snabble.sdk.coupons.Coupon
11+ import io.snabble.sdk.payment.PaymentCredentials
1212import io.snabble.sdk.shoppingcart.data.cart.BackendCart
1313import java.io.Serializable
14- import java.lang.Exception
15- import java.util.*
14+ import java.util.Date
1615
1716/* *
1817 * Interface for the snabble Checkout API
@@ -90,8 +89,8 @@ interface CheckoutInfoResult {
9089
9190 fun onNoShopFound ()
9291 fun onInvalidProducts (products : List <Product >)
92+ fun onInvalidItems (itemIds : List <String >)
9393 fun onNoAvailablePaymentMethodFound ()
94- fun onInvalidDepositReturnVoucher ()
9594 fun onUnknownError ()
9695 fun onConnectionError ()
9796}
@@ -111,7 +110,9 @@ enum class LineItemType {
111110 @SerializedName(" default" ) DEFAULT ,
112111 @SerializedName(" deposit" ) DEPOSIT ,
113112 @SerializedName(" discount" ) DISCOUNT ,
114- @SerializedName(" coupon" ) COUPON
113+ @SerializedName(" coupon" ) COUPON ,
114+ @SerializedName(" depositReturnVoucher" ) DEPOSIT_RETURN_VOUCHER ,
115+ @SerializedName(" depositReturn" ) DEPOSIT_RETURN
115116}
116117
117118enum class CheckState {
@@ -213,11 +214,28 @@ data class CheckoutInfo(
213214)
214215
215216data class Violation (
216- val type : String ? = null ,
217+ val type : ViolationType ? = null ,
217218 val refersTo : String? = null ,
218219 val message : String? = null ,
219220)
220221
222+ enum class ViolationType {
223+ @SerializedName(" deposit_return_voucher_already_redeemed" )
224+ DEPOSIT_RETURN_ALREADY_REDEEMED ,
225+
226+ @SerializedName(" deposit_return_voucher_duplicate" )
227+ DEPOSIT_RETURN_DUPLICATED ,
228+
229+ @SerializedName(" coupon_already_voided" )
230+ COUPON_ALREADY_VOIDED ,
231+
232+ @SerializedName(" coupon_currently_not_valid" )
233+ COUPON_CURRENTLY_NOT_VALID ,
234+
235+ @SerializedName(" coupon_invalid" )
236+ COUPON_INVALID ,
237+ }
238+
221239data class LineItem (
222240 val id : String? = null ,
223241 val amount : Int = 0 ,
@@ -317,11 +335,37 @@ data class Fulfillment(
317335 get() = links?.get(" self" )?.href
318336}
319337
338+ data class DepositReturnVoucher (
339+ @SerializedName(" refersTo" )
340+ val refersTo : String ,
341+ @SerializedName(" state" )
342+ val state : DepositReturnVoucherState
343+ )
344+
345+ enum class DepositReturnVoucherState {
346+ @SerializedName(" pending" )
347+ PENDING ,
348+
349+ @SerializedName(" redeemed" )
350+ REDEEMED ,
351+
352+ @SerializedName(" redeemingFailed" )
353+ REDEEMING_FAILED ,
354+
355+ @SerializedName(" rolledback" )
356+ ROLLED_BACK ,
357+
358+ @SerializedName(" rollbackFailed" )
359+ ROLLBACK_FAILED
360+ }
361+
320362data class CheckoutProcessResponse (
321363 val links : Map <String , Href >? = null ,
322364 val checks : List <Check > = emptyList(),
323365 @SerializedName(" orderID" )
324366 val orderId : String? = null ,
367+ @SerializedName(" depositReturnVouchers" )
368+ val depositReturnVouchers : List <DepositReturnVoucher >? = null ,
325369 val aborted : Boolean = false ,
326370 val paymentMethod : PaymentMethod ? = null ,
327371 val paymentInformation : PaymentInformation ? = null ,
0 commit comments