-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModels.kt
More file actions
72 lines (56 loc) · 1.53 KB
/
Models.kt
File metadata and controls
72 lines (56 loc) · 1.53 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
package com.shopify.example.storefront
import kotlinx.serialization.Serializable
// [START complete-tutorial.response-types]
@Serializable
data class ProductsResponse(val data: ProductsData)
@Serializable
data class ProductsData(val products: ProductConnection)
@Serializable
data class ProductConnection(val edges: List<ProductEdge>)
@Serializable
data class ProductEdge(val node: Product)
@Serializable
data class Product(
val id: String,
val title: String,
val description: String? = null,
val featuredImage: FeaturedImage? = null,
val variants: VariantConnection
) {
val firstVariantId: String?
get() = variants.edges.firstOrNull()?.node?.id
}
@Serializable
data class FeaturedImage(val url: String)
@Serializable
data class VariantConnection(val edges: List<VariantEdge>)
@Serializable
data class VariantEdge(val node: ProductVariant)
@Serializable
data class ProductVariant(
val id: String,
val title: String,
val price: Price
)
@Serializable
data class Price(val amount: String, val currencyCode: String)
@Serializable
data class CartCreateResponse(val data: CartCreateData)
@Serializable
data class CartCreateData(val cartCreate: CartCreatePayload)
@Serializable
data class CartCreatePayload(
val cart: Cart? = null,
val userErrors: List<UserError> = emptyList()
)
@Serializable
data class Cart(
val id: String,
val checkoutUrl: String
)
@Serializable
data class UserError(
val field: List<String>? = null,
val message: String
)
// [END complete-tutorial.response-types]