-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
92 changed files
with
3,072 additions
and
1,802 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 15 additions & 6 deletions
21
app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/StoreApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,37 @@ | ||
package dev.ragnarok.fenrir.api.impl | ||
|
||
import dev.ragnarok.fenrir.Constants | ||
import dev.ragnarok.fenrir.api.IServiceProvider | ||
import dev.ragnarok.fenrir.api.TokenType | ||
import dev.ragnarok.fenrir.api.interfaces.IStoreApi | ||
import dev.ragnarok.fenrir.api.model.VKApiStickerSetsData | ||
import dev.ragnarok.fenrir.api.model.Dictionary | ||
import dev.ragnarok.fenrir.api.model.Items | ||
import dev.ragnarok.fenrir.api.model.VKApiSticker | ||
import dev.ragnarok.fenrir.api.model.VKApiStickerSet | ||
import dev.ragnarok.fenrir.api.model.VKApiStickersKeywords | ||
import dev.ragnarok.fenrir.api.services.IStoreService | ||
import io.reactivex.rxjava3.core.Single | ||
|
||
internal class StoreApi(accountId: Long, provider: IServiceProvider) : | ||
AbsApi(accountId, provider), IStoreApi { | ||
override val stickerKeywords: Single<VKApiStickersKeywords> | ||
override val stickerKeywords: Single<Dictionary<VKApiStickersKeywords>> | ||
get() = provideService(IStoreService(), TokenType.USER) | ||
.flatMap { service -> | ||
service | ||
.getStickersKeywords("var dic=API.store.getStickersKeywords({'v':'" + Constants.API_VERSION + "','aliases':1,'all_products':1}).dictionary;return {'keywords': [email protected], 'words_stickers': [email protected]_stickers};") | ||
.getStickersKeywords() | ||
.map(extractResponseWithErrorHandling()) | ||
} | ||
override val stickers: Single<VKApiStickerSetsData> | ||
override val stickersSets: Single<Items<VKApiStickerSet.Product>> | ||
get() = provideService(IStoreService(), TokenType.USER) | ||
.flatMap { service -> | ||
service | ||
.getStickers("var pack = API.store.getProducts({'v':'" + Constants.API_VERSION + "','extended':1,'filters':'active','type':'stickers'}); var recent = API.messages.getRecentStickers(); return {'sticker_pack': pack, 'recent': recent};") | ||
.getStickersSets() | ||
.map(extractResponseWithErrorHandling()) | ||
} | ||
override val recentStickers: Single<Items<VKApiSticker>> | ||
get() = provideService(IStoreService(), TokenType.USER) | ||
.flatMap { service -> | ||
service | ||
.getRecentStickers() | ||
.map(extractResponseWithErrorHandling()) | ||
} | ||
} |
10 changes: 7 additions & 3 deletions
10
app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/interfaces/IStoreApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
package dev.ragnarok.fenrir.api.interfaces | ||
|
||
import dev.ragnarok.fenrir.api.model.VKApiStickerSetsData | ||
import dev.ragnarok.fenrir.api.model.Dictionary | ||
import dev.ragnarok.fenrir.api.model.Items | ||
import dev.ragnarok.fenrir.api.model.VKApiSticker | ||
import dev.ragnarok.fenrir.api.model.VKApiStickerSet | ||
import dev.ragnarok.fenrir.api.model.VKApiStickersKeywords | ||
import io.reactivex.rxjava3.core.Single | ||
|
||
interface IStoreApi { | ||
val stickerKeywords: Single<VKApiStickersKeywords> | ||
val stickers: Single<VKApiStickerSetsData> | ||
val stickerKeywords: Single<Dictionary<VKApiStickersKeywords>> | ||
val stickersSets: Single<Items<VKApiStickerSet.Product>> | ||
val recentStickers: Single<Items<VKApiSticker>> | ||
} |
13 changes: 13 additions & 0 deletions
13
app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/Dictionary.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package dev.ragnarok.fenrir.api.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
class Dictionary<I> { | ||
@SerialName("count") | ||
var count = 0 | ||
|
||
@SerialName("dictionary") | ||
var dictionary: ArrayList<I>? = null | ||
} |
13 changes: 0 additions & 13 deletions
13
app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/model/VKApiStickerSetsData.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 28 additions & 9 deletions
37
app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/services/IStoreService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,44 @@ | ||
package dev.ragnarok.fenrir.api.services | ||
|
||
import dev.ragnarok.fenrir.api.model.VKApiStickerSetsData | ||
import dev.ragnarok.fenrir.api.model.Dictionary | ||
import dev.ragnarok.fenrir.api.model.Items | ||
import dev.ragnarok.fenrir.api.model.VKApiSticker | ||
import dev.ragnarok.fenrir.api.model.VKApiStickerSet | ||
import dev.ragnarok.fenrir.api.model.VKApiStickersKeywords | ||
import dev.ragnarok.fenrir.api.model.response.BaseResponse | ||
import dev.ragnarok.fenrir.api.rest.IServiceRest | ||
import io.reactivex.rxjava3.core.Single | ||
|
||
class IStoreService : IServiceRest() { | ||
fun getStickers(code: String?): Single<BaseResponse<VKApiStickerSetsData>> { | ||
fun getRecentStickers(): Single<BaseResponse<Items<VKApiSticker>>> { | ||
return rest.request( | ||
"execute", | ||
form("code" to code), | ||
base(VKApiStickerSetsData.serializer()) | ||
"messages.getRecentStickers", | ||
null, | ||
items(VKApiSticker.serializer()) | ||
) | ||
} | ||
|
||
fun getStickersKeywords(code: String?): Single<BaseResponse<VKApiStickersKeywords>> { | ||
fun getStickersSets(): Single<BaseResponse<Items<VKApiStickerSet.Product>>> { | ||
return rest.request( | ||
"execute", | ||
form("code" to code), | ||
base(VKApiStickersKeywords.serializer()) | ||
"store.getProducts", | ||
form( | ||
"extended" to 1, | ||
"filters" to "active", | ||
"type" to "stickers" | ||
), | ||
items(VKApiStickerSet.Product.serializer()) | ||
) | ||
} | ||
|
||
fun getStickersKeywords(): Single<BaseResponse<Dictionary<VKApiStickersKeywords>>> { | ||
return rest.request( | ||
"store.getStickersKeywords", | ||
form( | ||
"aliases" to 1, | ||
"all_products" to 0, | ||
"need_stickers" to 1 | ||
), | ||
dictionary(VKApiStickersKeywords.serializer()) | ||
) | ||
} | ||
} |
Oops, something went wrong.