Documentation (beta_1.0) - UNIZAR-30226-2018-05/modelo-jvm GitHub Wiki

Facade

> fun login(mail: String, pass: String): Boolean

Log in using the mail and password of a user. If login is correct, the user data will be saved on UserLogged object.


> fun logout(): Boolean

Log out and remove th user data from UserLogged object.


> fun signup(mail: String, name: String, username: String, pass: String)

Sign up a new account.


> fun searchUsers(name: String = "", username: String = "", skip: Int = 0, limit: Int = 1): List<User>

Return a list (not mutable) from server of users (as User) that match with the parameters.


> fun searchSongs(name: String = "", author: String = "", genre: String = "", skip: Int = 0, limit: Int = 1): List<Song>

Return a list (not mutable) from server of songs (as Song) that match with the parameters.


> fun searchAlbums(name: String = "", author: String = "", skip: Int = 0, limit: Int = 1): List<Album>

Return a list (not mutable) from server of albums (as Album) that match with the parameters.


> fun searchAlbums(name: String = "", skip: Int = 0, limit: Int = 1): List<Author>

Return a list (not mutable) from server of authors (as Author) that match with the parameters.

UserLogged

> fun isLogged(): Boolean

Return true if there are an user logged


> fun getFavoritePlaylist(): Playlist

Return the favorite playlist (id 0) of the logged user.


> fun getAuthorsFromFavorite(): List<Author>

Return the authors of the songs on favorite playlist of the logged user.


> fun getAlbumsFromFavorite(): List<Album>

Return the albums of the songs on favorite playlist of the logged user.


> fun addToFavorite(song: Song): Boolean

Add a song to the favorite songs playlist.


> fun removeFromFavorite(index: Int): Boolean

Remove a song from the favorite songs playlist.


> fun newPlaylist(name: String, desc: String)

Create a new playlist with the logged user as the owner.


> fun removePlaylistAt(index: Int)

Remove a playlist from server and stored playlists list using the index of the stored playlists list. Use with caution: Procure that the list haven't been reorder.


> fun removePlaylist(playlistId: String)

Remove a playlist from the server and reload the stored playlist list. Use with caution: All user playlist must be downloaded again.


> fun newFriend(friendId: String)

Add a new friend (on server) and download and save it profile (as User) on the stored friends list.


> fun removeFriendAt(index: Int)

Remove a friend from server and stored friends list using the index of the stored friends list. Use with caution: Procure that the list haven't been reorder.


> fun removeFriend(friendId: String)

Remove a friend from the server and reload the stored friends list. Use with caution: All user data (including playlist, but they aren't updated) must be downloaded again.


> fun saveSession()

Save the current session (if is a session) on the server.


> fun restoreSession()

Restore the session saved on the server


> fun editUserInfo(username: String = "", name: String = "", bio: String = "")

Edit the basic information of the logged user.


> fun editCredentials(mail: String, pass: String)

Edit logged user credentials.


> fun editPlaylistInfo(name: String = "", description: String = "")

Edit the basic information of a playlist that logged user owns.


> fun getUser(): User

Return the logged user (as User)

Session

> fun isSessionStored(): Boolean

Returns if is any session stored here.

Album

> val id: String
> val songs: List<Song>
> val name: String
> val authorId: String
> val authorName: String
> val imageURL: String
> val desc: String
> val date: LocalDate

Author

> val id: String
> val name: String
> val bio: String
> val albums: List<Album>
> val imageURL: String

Playlist

> val owner: User
> val authors: List<Author> [ getAuthors() ]
> val albums: List<Album> [ getAlbums() ]
> val songs: List<Song> [ getSongs() ]

> fun getInfo(): Set<Any>

Get the information of this playlist as a Set of id:String (0), name:String (1), description:String (2), date:LocalDate (3), imageURL:String (4), songAmount:Int (5).

Song

> val id: String
> val name: String
> val authorID: String
> val authorName: String
> val albumID: String
> val albumName: String
> val length: String
> val genre: List<String>
> val imageURL: String
> val fileURL: String

User

> val friends: List<User> [ getFriends() ]
> val playlists: List<Playlist> [ getPlaylists() ]

> public fun getInfo(): Set<String>

Return the basic information of this user as a Set of id (0), username (1), name (2) and bio (3).

⚠️ **GitHub.com Fallback** ⚠️