aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/xyz/adjutor/aniki/presentation/Singletons.kt
blob: 827c7e34d88bfcf6992fad8b3cae39b567e7bd7b (plain)
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
package xyz.adjutor.aniki.presentation

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import xyz.adjutor.aniki.data.anime.AnimeApi
import xyz.adjutor.aniki.data.anime.SearchAnimeApi
import xyz.adjutor.aniki.data.anime.TopAnimeApi
import xyz.adjutor.aniki.data.manga.MangaApi
import xyz.adjutor.aniki.data.manga.SearchMangaApi
import xyz.adjutor.aniki.data.manga.TopMangaApi

class Singletons {

    companion object {
        val gson: Gson = GsonBuilder()
            .setLenient()
            .create()!!
        private const val BASE_URL = "https://api.jikan.moe/"

        val topMangaApi: TopMangaApi = Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build()
            .create(TopMangaApi::class.java)

        val searchMangaApi: SearchMangaApi = Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build()
            .create(SearchMangaApi::class.java)

        val mangaApi: MangaApi = Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build()
            .create(MangaApi::class.java)

        val topAnimeApi: TopAnimeApi = Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build()
            .create(TopAnimeApi::class.java)

        val searchAnimeApi: SearchAnimeApi = Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build()
            .create(SearchAnimeApi::class.java)

        val animeApi: AnimeApi = Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build()
            .create(AnimeApi::class.java)
    }
}