-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from MoviebaseApp/release/0.3.0
release/0.3.0
- Loading branch information
Showing
24 changed files
with
488 additions
and
85 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
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
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
16 changes: 16 additions & 0 deletions
16
tmdb-api/src/commonMain/kotlin/app/moviebase/tmdb/api/Tmdb4AuthenticationApi.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,8 +1,24 @@ | ||
package app.moviebase.tmdb.api | ||
|
||
import app.moviebase.tmdb.model.Tmdb4ListMeta | ||
import app.moviebase.tmdb.model.Tmdb4RedirectToBodyAuth | ||
import app.moviebase.tmdb.model.Tmdb4RequestTokenBody | ||
import app.moviebase.tmdb.model.TmdbPageResult | ||
import io.ktor.client.* | ||
import io.ktor.client.request.* | ||
|
||
class Tmdb4AuthenticationApi(private val client: HttpClient) { | ||
|
||
suspend fun requestToken(auth: Tmdb4RedirectToBodyAuth): TmdbPageResult<Tmdb4ListMeta> = client.post { | ||
endPointV4("auth", "request_token") | ||
json() | ||
body = auth | ||
} | ||
|
||
suspend fun accessToken(requestToken: Tmdb4RequestTokenBody): TmdbPageResult<Tmdb4ListMeta> = client.post { | ||
endPointV4("auth", "access_token") | ||
json() | ||
body = requestToken | ||
} | ||
|
||
} |
91 changes: 91 additions & 0 deletions
91
tmdb-api/src/commonMain/kotlin/app/moviebase/tmdb/api/Tmdb4ListApi.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,101 @@ | ||
package app.moviebase.tmdb.api | ||
|
||
import app.moviebase.tmdb.model.* | ||
import io.ktor.client.* | ||
import io.ktor.client.request.* | ||
|
||
class Tmdb4ListApi(private val client: HttpClient) { | ||
|
||
/** | ||
* This method will retrieve a list by id. | ||
* Private lists can only be accessed by their owners and therefore require a valid user access token. | ||
*/ | ||
suspend fun getList(listId: String): Tmdb4List = client.get { | ||
endPointList(listId) | ||
} | ||
|
||
/** | ||
* This method will create a new list. | ||
* You will need to have valid user access token in order to create a new list. | ||
*/ | ||
suspend fun create(request: Tmdb4CreateListRequest): TmdbStatusResult = client.post { | ||
endPointV4("list") | ||
json() | ||
body = request | ||
} | ||
|
||
/** | ||
* This method will let you update the details of a list. | ||
* You must be the owner of the list and therefore have a valid user access token in order to edit it. | ||
*/ | ||
suspend fun update(listId: String, request: Tmdb4UpdateListRequest): TmdbStatusResult = client.put { | ||
endPointList(listId) | ||
json() | ||
body = request | ||
} | ||
|
||
/** | ||
* This method lets you clear all of the items from a list in a single request. This action cannot be reversed so use it with caution. | ||
* You must be the owner of the list and therefore have a valid user access token in order to clear a list. | ||
*/ | ||
suspend fun clear(listId: String): TmdbStatusResult = client.get { | ||
endPointList(listId, "clear") | ||
} | ||
|
||
/** | ||
* This method will delete a list by id. This action is not reversible so take care when issuing it. | ||
* You must be the owner of the list and therefore have a valid user access token in order to delete it. | ||
*/ | ||
suspend fun delete(listId: String): TmdbStatusResult = client.delete { | ||
endPointList(listId) | ||
} | ||
|
||
/** | ||
* This method will let you add items to a list. We support essentially an unlimited number of items to be posted at a time. Both movie and TV series are support. | ||
* The results of this query will return a results array. Each result includes a success field. If a result is false this will usually indicate that the item already exists on the list. It may also indicate that the item could not be found. | ||
* You must be the owner of the list and therefore have a valid user access token in order to add items to a list. | ||
*/ | ||
suspend fun addItems(listId: String, items: Tmdb4ItemsRequest): TmdbStatusResult = client.post { | ||
endPointList(listId, "items") | ||
|
||
json() | ||
body = items | ||
} | ||
|
||
/** | ||
* This method will let you update an individual item on a list. Currently, only adding a comment is suported. | ||
* You must be the owner of the list and therefore have a valid user access token in order to edit items. | ||
*/ | ||
suspend fun updateItems(listId: String, items: Tmdb4UpdateItemsRequest): TmdbStatusResult = client.put { | ||
endPointList(listId, "items") | ||
|
||
json() | ||
body = items | ||
} | ||
|
||
/** | ||
* This method will let you remove items from a list. You can remove multiple items at a time. | ||
* You must be the owner of the list and therefore have a valid user access token in order to delete items from it. | ||
*/ | ||
suspend fun removeItems(listId: String, items: Tmdb4ItemsRequest): TmdbStatusResult = client.delete { | ||
endPointList(listId, "items") | ||
|
||
json() | ||
body = items | ||
} | ||
|
||
/** | ||
* This method lets you quickly check if the item is already added to the list. | ||
* You must be the owner of the list and therefore have a valid user access token in order to check an item status. | ||
*/ | ||
suspend fun checkItemStatus(listId: String, mediaId: Int, mediaType: TmdbMediaType): Tmdb4ItemStatus = client.get { | ||
endPointList(listId, "item_status") | ||
parameter("media_id", mediaId.toString()) | ||
parameter("media_type", mediaType.value) | ||
} | ||
|
||
private fun HttpRequestBuilder.endPointList(listId: String, vararg paths: String) { | ||
endPointV4("list", listId, *paths) | ||
} | ||
|
||
} |
16 changes: 10 additions & 6 deletions
16
tmdb-api/src/commonMain/kotlin/app/moviebase/tmdb/api/TmdbAccountApi.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,32 +1,36 @@ | ||
package app.moviebase.tmdb.api | ||
|
||
import app.moviebase.tmdb.model.AccountDetails | ||
import app.moviebase.tmdb.model.TmdbAccountDetails | ||
import app.moviebase.tmdb.model.TmdbFavoriteRequestBody | ||
import app.moviebase.tmdb.model.TmdbWatchlistRequestBody | ||
import io.ktor.client.* | ||
import io.ktor.client.request.* | ||
|
||
class TmdbAccountApi(private val client: HttpClient) { | ||
|
||
suspend fun getDetails(sessionId: String): AccountDetails = client.get { | ||
suspend fun getDetails(sessionId: String): TmdbAccountDetails = client.get { | ||
endPointV3("account") | ||
parameter("session_id", sessionId) | ||
} | ||
|
||
suspend fun markFavorite(accountId: String, requestBody: TmdbFavoriteRequestBody): AccountDetails = client.post { | ||
endPointV3("account", accountId, "favorite") | ||
suspend fun markFavorite(accountId: String, requestBody: TmdbFavoriteRequestBody): TmdbAccountDetails = client.post { | ||
endPointAccount(accountId, "favorite") | ||
parameter("account_id", accountId) | ||
json() | ||
|
||
body = requestBody | ||
} | ||
|
||
suspend fun markWatchlist(accountId: String, requestBody: TmdbWatchlistRequestBody): AccountDetails = client.post { | ||
endPointV3("account", accountId, "favorite") | ||
suspend fun markWatchlist(accountId: String, requestBody: TmdbWatchlistRequestBody): TmdbAccountDetails = client.post { | ||
endPointAccount(accountId, "favorite") | ||
parameter("account_id", accountId) | ||
json() | ||
|
||
body = requestBody | ||
} | ||
|
||
private fun HttpRequestBuilder.endPointAccount(accountId: String, vararg paths: String) { | ||
endPointV3("account", accountId, *paths) | ||
} | ||
|
||
} |
Oops, something went wrong.