Class UserRepository
- java.lang.Object
-
- edu.cnm.deepdive.cardcombat.service.UserRepository
-
-
Constructor Summary
Constructors Constructor Description UserRepository(Context context)
The constructor initializes the context, the database, the dao, and the GoogleSignInService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Completable
delete(User user)
Deletes a user record in the database.LiveData<User>
get(long id)
Returns LiveData on a user, given their id.Single<User>
getOrCreate(GoogleSignInAccount account)
Creates a player record in the database given a Google Sign In account.Completable
save(User user)
Creates or updates a player record in the database.
-
-
-
Constructor Detail
-
UserRepository
public UserRepository(Context context)
The constructor initializes the context, the database, the dao, and the GoogleSignInService.- Parameters:
context
- The application context.
-
-
Method Detail
-
getOrCreate
public Single<User> getOrCreate(@NonNull GoogleSignInAccount account)
Creates a player record in the database given a Google Sign In account.- Parameters:
account
- A GoogleSignInAccount that will be associated with the player.- Returns:
- A
Single
User
that has been created.
-
save
public Completable save(User user)
Creates or updates a player record in the database.- Parameters:
user
- TheUser
entity.- Returns:
- A
Completable
indicating the success or failure of the creation/update.
-
delete
public Completable delete(User user)
Deletes a user record in the database.- Parameters:
user
- ThePlayer
entity.- Returns:
- A
Completable
indicating the success or failure of the deletion.
-
-