-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathDocGetObjects.kt
90 lines (78 loc) · 2.61 KB
/
DocGetObjects.kt
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package documentation.methods.indexing
import com.algolia.search.dsl.requestOptions
import com.algolia.search.model.Attribute
import com.algolia.search.model.ObjectID
import com.algolia.search.model.indexing.Indexable
import com.algolia.search.model.multicluster.UserID
import documentation.index
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.Serializable
import kotlin.test.Ignore
import kotlin.test.Test
@Ignore
internal class DocGetObjects {
// suspend fun <T : Indexable> Index.getObject(
// serializer: __KSerializer<T>__,
// #{objectID}: __ObjectID__,
// #{attributesToRetrieve}: __List<Attribute>?__ = null,
// #{requestOptions}: __RequestOptions?__ = null
// ): T
//
// suspend fun Index.getObject(
// #{objectID}: __ObjectID__,
// #{attributesToRetrieve}: __List<Attribute>?__ = null,
// #{requestOptions}: __RequestOptions?__ = null
// ): JsonObject
//
// suspend fun Index.getObjects(
// #{objectIDs}: __List<ObjectID>__,
// #{attributesToRetrieve}: __List<Attribute>?__ = null,
// #{requestOptions}: __RequestOptions?__ = null
// ): ResponseObjects
@Serializable
data class Contact(
val firstname: String,
val lastname: String,
override val objectID: ObjectID
) : Indexable
@Test
fun snippet1() {
runTest {
index.getObject(ObjectID("myID1"))
}
}
@Test
fun snippet2() {
runTest {
val objectID = ObjectID("myID1")
index.getObject(objectID)
index.getObject(Contact.serializer(), objectID)
}
}
@Test
fun snippet3() {
runTest {
index.getObjects(listOf(ObjectID("myID1"), ObjectID("myID2")))
index.getObjects(Contact.serializer(), listOf(ObjectID("myID1"), ObjectID("myID2")))
}
}
@Test
fun snippet4() {
runTest {
val objectIDs = listOf(ObjectID("myID1"), ObjectID("myID2"))
val attributes = listOf(Attribute("firstname"), Attribute("lastname"))
index.getObjects(objectIDs, attributes)
index.getObjects(Contact.serializer(), objectIDs, attributes)
}
}
@Test
fun snippet5() {
runTest {
val requestOptions = requestOptions {
headerAlgoliaUserId(UserID("user123"))
}
index.getObjects(listOf(ObjectID("myID1"), ObjectID("myID2")), requestOptions = requestOptions)
index.getObjects(Contact.serializer(), listOf(ObjectID("myID1"), ObjectID("myID2")), requestOptions = requestOptions)
}
}
}