Newer
Older
CitrusClient / app / src / main / java / com / example / citrusclient / rest / TodosRest.java
package com.example.citrusclient.rest;

import com.example.citrusclient.models.Todo;

import java.util.ArrayList;
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;
import retrofit2.http.Query;

public interface TodosRest {

    @GET("/accounts/{account_id}/books/{book_id}/todos")
    Call<HashMap<Integer, HashMap<Integer, HashMap<Integer, HashMap<Integer, Todo>>>>> getAllTodos(
            @Path("account_id") String accountId,
            @Path("book_id") Integer bookId,
            @Query("token") String token
    );

    @GET("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}")
    Call<HashMap<Integer, HashMap<Integer, Todo>>> getTodosByMonth(
            @Path("account_id") String accountId,
            @Path("book_id") Integer bookId,
            @Path("year") Integer year,
            @Path("month") Integer month,
            @Query("token") String token
    );

    @GET("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}")
    Call<HashMap<Integer, Todo>> getTodosByDay(
            @Path("account_id") String accountId,
            @Path("book_id") Integer bookId,
            @Path("year") Integer year,
            @Path("month") Integer month,
            @Path("day") Integer day,
            @Query("token") String token
    );

    @GET("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}")
    Call<Todo> getTodoById(
            @Path("account_id") String accountId,
            @Path("book_id") Integer bookId,
            @Path("year") Integer year,
            @Path("month") Integer month,
            @Path("day") Integer day,
            @Path("todo_id") Integer todoId,
            @Query("token") String token
    );

    @FormUrlEncoded
    @POST("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}")
    Call<Todo> createTodo(
            @Path("account_id") String accountId,
            @Path("book_id") Integer bookId,
            @Path("year") Integer year,
            @Path("month") Integer month,
            @Path("day") Integer day,
            @Field("title") String title,
            @Field("token") String token
    );
    @FormUrlEncoded
    @PUT("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}/check")
    Call<Void> setCheck(
            @Path("account_id") String accountId,
            @Path("book_id") Integer bookId,
            @Path("year") Integer year,
            @Path("month") Integer month,
            @Path("day") Integer day,
            @Path("todo_id") Integer todoId,
            @Field("check") boolean check,
            @Field("token") String token
    );

    @DELETE("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}")
    Call<Void> deleteTodoById(
            @Path("account_id") String accountId,
            @Path("book_id") Integer bookId,
            @Path("year") Integer year,
            @Path("month") Integer month,
            @Path("day") Integer day,
            @Path("todo_id") Integer todoId,
            @Query("token") String token
    );


}