-
Notifications
You must be signed in to change notification settings - Fork 16
/
MastodonLists.kt
42 lines (38 loc) · 1.28 KB
/
MastodonLists.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
package social.bigbone.api.method
import social.bigbone.MastodonClient
import social.bigbone.MastodonRequest
import social.bigbone.api.Pageable
import social.bigbone.api.Range
import social.bigbone.api.entity.MastodonList
import social.bigbone.api.entity.Status
import social.bigbone.api.exception.BigboneRequestException
class MastodonLists(private val client: MastodonClient) {
// GET /api/v1/lists
fun getLists(): MastodonRequest<Pageable<MastodonList>> {
return MastodonRequest<Pageable<MastodonList>>(
{
client.get(
"api/v1/lists"
)
},
{
client.getSerializer().fromJson(it, MastodonList::class.java)
}
).toPageable()
}
// GET /api/v1/timelines/list/:list_id
@Throws(BigboneRequestException::class)
fun getListTimeLine(listID: String, range: Range = Range()): MastodonRequest<Pageable<Status>> {
return MastodonRequest<Pageable<Status>>(
{
client.get(
"api/v1/timelines/list/$listID",
range.toParameter()
)
},
{
client.getSerializer().fromJson(it, Status::class.java)
}
).toPageable()
}
}