Refacotor some package & add book / detail response to the API.
This commit is contained in:
		
							parent
							
								
									31b6aed8a8
								
							
						
					
					
						commit
						4ede938017
					
				
					 15 changed files with 134 additions and 30 deletions
				
			
		| 
						 | 
				
			
			@ -1,11 +1,10 @@
 | 
			
		|||
package com.pixelized.biblib.network.client
 | 
			
		||||
 | 
			
		||||
import com.pixelized.biblib.data.network.query.AuthLoginQuery
 | 
			
		||||
import com.pixelized.biblib.data.network.response.AuthLoginResponse
 | 
			
		||||
import retrofit2.http.Body
 | 
			
		||||
import retrofit2.http.GET
 | 
			
		||||
import retrofit2.http.POST
 | 
			
		||||
import retrofit2.http.Query
 | 
			
		||||
import com.pixelized.biblib.network.data.query.AuthLoginQuery
 | 
			
		||||
import com.pixelized.biblib.network.data.response.AuthLoginResponse
 | 
			
		||||
import com.pixelized.biblib.network.data.response.BookDetailResponse
 | 
			
		||||
import com.pixelized.biblib.network.data.response.BookListResponse
 | 
			
		||||
import retrofit2.http.*
 | 
			
		||||
 | 
			
		||||
interface IBibLibWebServiceAPI {
 | 
			
		||||
    @POST("/authent/login")
 | 
			
		||||
| 
						 | 
				
			
			@ -16,16 +15,16 @@ interface IBibLibWebServiceAPI {
 | 
			
		|||
 | 
			
		||||
//    @GET("/authent/user")
 | 
			
		||||
//    suspend fun user(): UserResponse
 | 
			
		||||
//
 | 
			
		||||
//    @GET("/api/book/new")
 | 
			
		||||
//    suspend fun new(): BookListResponse
 | 
			
		||||
//
 | 
			
		||||
//    @GET("/api/book")
 | 
			
		||||
//    suspend fun list(): BookListResponse
 | 
			
		||||
//
 | 
			
		||||
//    @GET("/api/book/{id}")
 | 
			
		||||
//    suspend fun detail(@Path("id") bookId: Int): BookDetailResponse
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
    @GET("/api/book/new")
 | 
			
		||||
    suspend fun new(): BookListResponse
 | 
			
		||||
 | 
			
		||||
    @GET("/api/book")
 | 
			
		||||
    suspend fun list(): BookListResponse
 | 
			
		||||
 | 
			
		||||
    @GET("/api/book/{id}")
 | 
			
		||||
    suspend fun detail(@Path("id") bookId: Int): BookDetailResponse
 | 
			
		||||
 | 
			
		||||
//    @GET("/api/book/{id}/send/kindle")
 | 
			
		||||
//    suspend fun send(@Path("id") bookId: Int, @Query("mail") mail: String): LinkedTreeMap<String, Any>
 | 
			
		||||
//
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
package com.pixelized.biblib.data.network.query
 | 
			
		||||
package com.pixelized.biblib.network.data.query
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
package com.pixelized.biblib.data.network.response
 | 
			
		||||
package com.pixelized.biblib.network.data.response
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,63 @@
 | 
			
		|||
package com.pixelized.biblib.network.data.response
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName
 | 
			
		||||
 | 
			
		||||
data class BookDetailResponse(
 | 
			
		||||
    @SerializedName("book_id")
 | 
			
		||||
    val book_id: Int? = null,
 | 
			
		||||
    @SerializedName("book_title")
 | 
			
		||||
    val book_title: String? = null,
 | 
			
		||||
    @SerializedName("book_sort")
 | 
			
		||||
    val book_sort: String? = null,
 | 
			
		||||
    @SerializedName("book_has_cover")
 | 
			
		||||
    val book_has_cover: Int? = null,
 | 
			
		||||
    @SerializedName("book_date")
 | 
			
		||||
    val book_date: String? = null,
 | 
			
		||||
    @SerializedName("book_series_index")
 | 
			
		||||
    val book_series_index: Float? = null,
 | 
			
		||||
    @SerializedName("timestamp")
 | 
			
		||||
    val timestamp: String? = null,
 | 
			
		||||
    @SerializedName("last_modified")
 | 
			
		||||
    val last_modified: String? = null,
 | 
			
		||||
    @SerializedName("author_id")
 | 
			
		||||
    val author_id: List<String>? = null,
 | 
			
		||||
    @SerializedName("author_name")
 | 
			
		||||
    val author_name: List<String>? = null,
 | 
			
		||||
    @SerializedName("author_sort")
 | 
			
		||||
    val author_sort: List<String>? = null,
 | 
			
		||||
    @SerializedName("lang_id")
 | 
			
		||||
    val lang_id: String? = null,
 | 
			
		||||
    @SerializedName("lang_code")
 | 
			
		||||
    val lang_code: String? = null,
 | 
			
		||||
    @SerializedName("tag_id")
 | 
			
		||||
    val tag_id: List<String>? = null,
 | 
			
		||||
    @SerializedName("tag_name")
 | 
			
		||||
    val tag_name: List<String>? = null,
 | 
			
		||||
    @SerializedName("rating")
 | 
			
		||||
    val rating: String? = null,
 | 
			
		||||
    @SerializedName("series_id")
 | 
			
		||||
    val series_id: String? = null,
 | 
			
		||||
    @SerializedName("series_name")
 | 
			
		||||
    val series_name: String? = null,
 | 
			
		||||
    @SerializedName("series_sort")
 | 
			
		||||
    val series_sort: String? = null,
 | 
			
		||||
    @SerializedName("comment")
 | 
			
		||||
    val comment: String? = null,
 | 
			
		||||
    @SerializedName("data")
 | 
			
		||||
    val data: List<Data>? = null,
 | 
			
		||||
) : ErrorResponse() {
 | 
			
		||||
    data class Data(
 | 
			
		||||
        // "data_id": "9344",
 | 
			
		||||
        @SerializedName("data_id")
 | 
			
		||||
        val data_id: String? = null,
 | 
			
		||||
        // "data_format": "MOBI",
 | 
			
		||||
        @SerializedName("data_format")
 | 
			
		||||
        val data_format: String? = null,
 | 
			
		||||
        // "data_size": "699027",
 | 
			
		||||
        @SerializedName("data_size")
 | 
			
		||||
        val data_size: String? = null,
 | 
			
		||||
        // "data_name": "Fondation - Isaac Asimov"
 | 
			
		||||
        @SerializedName("data_name")
 | 
			
		||||
        val data_name: String? = null,
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
package com.pixelized.biblib.network.data.response
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName
 | 
			
		||||
 | 
			
		||||
data class BookListResponse(
 | 
			
		||||
    @SerializedName("lastUpdated")
 | 
			
		||||
    val lastUpdated: String? = null,        // "2020-12-16T23:50:34.258Z"
 | 
			
		||||
    @SerializedName("data")
 | 
			
		||||
    val data: List<Book>? = null,
 | 
			
		||||
) : ErrorResponse() {
 | 
			
		||||
    data class Book(
 | 
			
		||||
        @SerializedName("book_id")
 | 
			
		||||
        val book_id: Int?,                  //"book_id": 9670,
 | 
			
		||||
        @SerializedName("book_title")
 | 
			
		||||
        val book_title: String?,            //"book_title": "L’Inconnu de la forêt",
 | 
			
		||||
        @SerializedName("book_sort")
 | 
			
		||||
        val book_sort: String?,             //"book_sort": "L’Inconnu de la forêt",
 | 
			
		||||
        @SerializedName("author_sort")
 | 
			
		||||
        val author_sort: List<String>?,     //"author_sort": ["Coben, Harlan"],
 | 
			
		||||
        @SerializedName("book_has_cover")
 | 
			
		||||
        val book_has_cover: Int?,           //"book_has_cover": 1,
 | 
			
		||||
        @SerializedName("book_date")
 | 
			
		||||
        val book_date: String?,             //"book_date": "2020-10-15T06:21:32.000Z",
 | 
			
		||||
        @SerializedName("last_modified")
 | 
			
		||||
        val last_modified: String?,         //"last_modified": "2020-11-08T17:15:23.916Z",
 | 
			
		||||
        @SerializedName("author_id")
 | 
			
		||||
        val author_id: List<String>?,       //"author_id": ["214"],
 | 
			
		||||
        @SerializedName("author_name")
 | 
			
		||||
        val author_name: List<String>?,     //"author_name": ["Harlan Coben"],
 | 
			
		||||
        @SerializedName("lang_id")
 | 
			
		||||
        val lang_id: String?,               //"lang_id": "1",
 | 
			
		||||
        @SerializedName("lang_code")
 | 
			
		||||
        val lang_code: String?,             //"lang_code": "fra",
 | 
			
		||||
        @SerializedName("rating")
 | 
			
		||||
        val rating: String?,                //"rating": null, TODO: examples are all null, type unknowed
 | 
			
		||||
        @SerializedName("series_name")
 | 
			
		||||
        val series_name: String?,           //"series_name": null,
 | 
			
		||||
        @SerializedName("series_sort")
 | 
			
		||||
        val series_sort: String?,           //"series_sort": null,
 | 
			
		||||
        @SerializedName("book_series_index")
 | 
			
		||||
        val book_series_index: Float?,      //"book_series_index": 1,
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
package com.pixelized.biblib.data.network.response
 | 
			
		||||
package com.pixelized.biblib.network.data.response
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ import androidx.compose.ui.text.style.TextOverflow
 | 
			
		|||
import androidx.compose.ui.tooling.preview.Preview
 | 
			
		||||
import androidx.compose.ui.unit.dp
 | 
			
		||||
import com.pixelized.biblib.R
 | 
			
		||||
import com.pixelized.biblib.data.ui.BookThumbnailUio
 | 
			
		||||
import com.pixelized.biblib.ui.data.BookThumbnailUio
 | 
			
		||||
import com.pixelized.biblib.ui.theme.BibLibTheme
 | 
			
		||||
import com.pixelized.biblib.ui.theme.Teal200
 | 
			
		||||
import com.pixelized.biblib.utils.BitmapCache
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ import androidx.compose.ui.res.stringResource
 | 
			
		|||
import androidx.compose.ui.tooling.preview.Preview
 | 
			
		||||
import androidx.compose.ui.unit.dp
 | 
			
		||||
import com.pixelized.biblib.R
 | 
			
		||||
import com.pixelized.biblib.data.ui.BookUio
 | 
			
		||||
import com.pixelized.biblib.ui.data.BookUio
 | 
			
		||||
import com.pixelized.biblib.ui.composable.items.Image
 | 
			
		||||
import com.pixelized.biblib.ui.theme.BibLibTheme
 | 
			
		||||
import com.pixelized.biblib.ui.theme.Teal200
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
package com.pixelized.biblib.data.ui
 | 
			
		||||
package com.pixelized.biblib.ui.data
 | 
			
		||||
 | 
			
		||||
import com.pixelized.biblib.network.client.IBibLibClient.Companion.THUMBNAIL_URL
 | 
			
		||||
import java.net.URL
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
package com.pixelized.biblib.data.ui
 | 
			
		||||
package com.pixelized.biblib.ui.data
 | 
			
		||||
 | 
			
		||||
import com.pixelized.biblib.network.client.IBibLibClient.Companion.COVER_URL
 | 
			
		||||
import java.net.URL
 | 
			
		||||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ import androidx.lifecycle.viewModelScope
 | 
			
		|||
import com.google.android.gms.auth.api.signin.GoogleSignIn
 | 
			
		||||
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
 | 
			
		||||
import com.google.android.gms.common.api.ApiException
 | 
			
		||||
import com.pixelized.biblib.data.network.query.AuthLoginQuery
 | 
			
		||||
import com.pixelized.biblib.network.data.query.AuthLoginQuery
 | 
			
		||||
import com.pixelized.biblib.network.client.IBibLibClient
 | 
			
		||||
import com.pixelized.biblib.repository.credential.ICredentialRepository
 | 
			
		||||
import com.pixelized.biblib.repository.googlesignin.IGoogleSingInRepository
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +20,6 @@ import com.pixelized.biblib.ui.viewmodel.authentication.IAuthentication.State
 | 
			
		|||
import com.pixelized.biblib.utils.exception.MissingTokenException
 | 
			
		||||
import com.pixelized.biblib.utils.injection.inject
 | 
			
		||||
import kotlinx.coroutines.Dispatchers
 | 
			
		||||
import kotlinx.coroutines.delay
 | 
			
		||||
import kotlinx.coroutines.launch
 | 
			
		||||
 | 
			
		||||
class AuthenticationViewModel : ViewModel(), IAuthentication {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@ package com.pixelized.biblib.ui.viewmodel.navigation
 | 
			
		|||
 | 
			
		||||
import androidx.lifecycle.LiveData
 | 
			
		||||
import androidx.lifecycle.MutableLiveData
 | 
			
		||||
import com.pixelized.biblib.data.ui.BookUio
 | 
			
		||||
import com.pixelized.biblib.ui.data.BookUio
 | 
			
		||||
 | 
			
		||||
interface INavigation {
 | 
			
		||||
    val screen: LiveData<Screen>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
package com.pixelized.biblib.utils.extention
 | 
			
		||||
 | 
			
		||||
import com.pixelized.biblib.data.ui.BookThumbnailUio
 | 
			
		||||
import com.pixelized.biblib.data.ui.BookUio
 | 
			
		||||
import com.pixelized.biblib.ui.data.BookThumbnailUio
 | 
			
		||||
import com.pixelized.biblib.ui.data.BookUio
 | 
			
		||||
 | 
			
		||||
fun BookThumbnailUio.toBookUio(): BookUio {
 | 
			
		||||
    return BookUio(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
package com.pixelized.biblib.utils.mock
 | 
			
		||||
 | 
			
		||||
import com.pixelized.biblib.data.ui.BookUio
 | 
			
		||||
import com.pixelized.biblib.ui.data.BookUio
 | 
			
		||||
 | 
			
		||||
class BookMock {
 | 
			
		||||
    val book: BookUio = BookUio(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
package com.pixelized.biblib.utils.mock
 | 
			
		||||
 | 
			
		||||
import com.pixelized.biblib.data.ui.BookThumbnailUio
 | 
			
		||||
import com.pixelized.biblib.ui.data.BookThumbnailUio
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BookThumbnailMock {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue