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.AccountJson;
import com.example.nemophila.entities.PostJson;

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

import retrofit2.Call;
import retrofit2.Response;
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<AccountJson> createAccounts(
            @Field("name") String name,
            @Field("pw") String pw
    );

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

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

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

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

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

    @GET("accounts/{uid}/posts")
    Call<Collection<PostJson>> getAccountPosts(
            @Path("uid") String uid
    );

    @DELETE("shops/{sid}/posts/{uid}/{pid}")
    Call<Void> deletePost(
            @Path("sid") String sid,
            @Path("uid") String uid,
            @Path("pid") String pid,
            @Field("token") String token
    );
}