Newer
Older
NemophilaClient / app / src / main / java / com / example / nemophila / resources / AccountsRest.java
package com.example.nemophila.resources;

//import android.accounts.Account;

import com.example.nemophila.entities.Account;
import com.example.nemophila.entities.Post;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;

import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;

public interface AccountsRest {
    @GET("accounts")
    Call<HashMap> getAccounts();

    @FormUrlEncoded
    @POST("accounts")
    Call<Account> createAccounts(
            @Field("name") String name,
            @Field("pw") String pw
    );

    @GET("accounts/{uid}")
    Call<Account> getAccount(
            @Path("uid") String uid
    );

    @DELETE("accounts/{uid}")
    Call<Void> deleteAccount(
            @Path("uid") String uid
    );

    @FormUrlEncoded
    @POST("accounts/{uid}/login")
    Call<Account> getAccounts(
            @Path("uid") String uid,
            @Field("pw")String pw
    );

    @FormUrlEncoded
    @PUT("accounts/{uid}/pw")
    Call<Void> changePw(
            @Path("uid") String uid,
            @Field("oldPw") String oldPw,
            @Field("newPw") String newPw,
            @Field("token") String token
    );

    @FormUrlEncoded
    @PUT("accounts/{uid}/name")
    Call<Void> changeName(
            @Path("uid") String uid,
            @Field("name") String name,
            @Field("token") String token
    );
    
}