com.github.stormbit.vksdk.clients.GroupClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vk-bot-sdk-kotlin Show documentation
Show all versions of vk-bot-sdk-kotlin Show documentation
The Kotlin library for working with VK api
The newest version!
package com.github.stormbit.vksdk.clients
import com.github.stormbit.vksdk.longpoll.LongPoll
import com.github.stormbit.vksdk.objects.upload.Upload
import com.github.stormbit.vksdk.utils.VK_API_VERSION
import com.github.stormbit.vksdk.utils.append
import com.github.stormbit.vksdk.vkapi.methods.docs.DocsApi
import com.github.stormbit.vksdk.vkapi.methods.friends.FriendsApi
import com.github.stormbit.vksdk.vkapi.methods.groups.GroupsApi
import com.github.stormbit.vksdk.vkapi.methods.likes.LikesApi
import com.github.stormbit.vksdk.vkapi.methods.messages.MessagesApi
import com.github.stormbit.vksdk.vkapi.methods.photos.PhotosApi
import com.github.stormbit.vksdk.vkapi.methods.users.UsersApi
import com.github.stormbit.vksdk.vkapi.methods.video.VideoApi
import com.github.stormbit.vksdk.vkapi.methods.wall.WallApi
import io.ktor.client.*
import io.ktor.http.*
/**
* Community client
*
* @param accessToken Access token of VK Group
* @param groupId ID of VK Group
*/
@Suppress("unused")
class GroupClient(
private val accessToken: String,
val groupId: Int,
httpClient: HttpClient
) : Client(httpClient) {
override val longPoll: LongPoll = LongPoll(this)
override val messages: MessagesApi = MessagesApi(this)
override val groups: GroupsApi = GroupsApi(this)
override val users: UsersApi = UsersApi(this)
override val photos: PhotosApi = PhotosApi(this)
override val video: VideoApi = VideoApi(this)
override val docs: DocsApi = DocsApi(this)
override val friends: FriendsApi = FriendsApi(this)
override val likes: LikesApi = LikesApi(this)
override val wall: WallApi = WallApi(this)
override val upload: Upload = Upload(this)
fun auth(): GroupClient {
token = accessToken
id = groupId
baseParams = Parameters.build {
append("v", VK_API_VERSION)
append("access_token", token)
}
log.info("Client object created with id: $id")
return this
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy