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

import com.example.citrusclient.models.Schedule;

import java.util.HashMap;

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

public interface ScheduleRest {

    String BASE_URL = "accounts/{account_id}/schedule";

    @GET(BASE_URL)
    Call<HashMap<Integer, //年
        HashMap<Integer, //月
        HashMap<Integer, //日
        HashMap<Integer, //Id
                Schedule>>>>> getAllSchedules(
            @Path("account_id") String accountId,
            @Query("token") String token
    );

    @GET(BASE_URL + "/{year}")
    Call<HashMap<Integer, //月
        HashMap<Integer, //日
        HashMap<Integer, //Id
        Schedule>>>> getSchedulesByYear(
            @Path("account_id") String accountId,
            @Path("year") int year,
            @Query("token") String token
    );

    @GET(BASE_URL + "/{year}/{month}")
    Call<HashMap<Integer, //日
        HashMap<Integer, //Id
            Schedule>>> getSchedulesByMonth(
        @Path("account_id") String accountId,
        @Path("year") int year,
        @Path("month") int month,
        @Query("token") String token
    );

    @GET(BASE_URL + "/{year}/{month}/{day}")
    Call<HashMap<Integer, //Id
        Schedule>> getSchedulesByDay(
        @Path("account_id") String accountId,
        @Path("year") int year,
        @Path("month") int month,
        @Path("day") int day,
        @Query("token") String token
    );

    @GET(BASE_URL + "/{year}/{month}")
    Call<HashMap<Integer, //日
            HashMap<Integer, //Id
                    Schedule>>> getScheduleByMonthAndBookId(
            @Path("account_id") String accountId,
            @Path("year") int year,
            @Path("month") int month,
            @Query("book_id") int bookId,
            @Query("token") String token
    );

    @GET(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
    Call<Schedule> getScheduleById(
        @Path("account_id") String accountId,
        @Path("year") int year,
        @Path("month") int month,
        @Path("day") int day,
        @Path("schedule_id") int id,
        @Query("token") String token
    );



    @FormUrlEncoded
    @POST(BASE_URL + "/{year}/{month}/{day}")
    Call<Schedule> createSchedule(
        @Path("account_id") String accountId,
        @Path("year") int year,
        @Path("month") int month,
        @Path("day") int day,
        @Field("title") String title,
        @Field("start_time") String startTime,
        @Field("end_time") String endTime,
        @Field("book_id") int bookId,
        @Field("token") String token
    );

    @DELETE(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
    Call<String> deleteScheduleById(
        @Path("account_id") String accountId,
        @Path("year") int year,
        @Path("month") int month,
        @Path("day") int day,
        @Path("schedule_id") int scheduleId,
        @Query("token") String token
    );

    @FormUrlEncoded
    @PUT(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
    Call<String> putStartTime(
        @Path("account_id") String accountId,
        @Path("year") int year,
        @Path("month") int month,
        @Path("day") int day,
        @Path("schedule_id") int scheduleId,
        @Field("token") String token,
        @Field("start_time") String startTime
    );

    @FormUrlEncoded
    @PUT(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
    Call<String> putEndTime(
            @Path("account_id") String accountId,
            @Path("year") int year,
            @Path("month") int month,
            @Path("day") int day,
            @Path("schedule_id") int scheduleId,
            @Field("token") String token,
            @Field("end_time") String endTime
    );

    @FormUrlEncoded
    @PUT(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
    Call<String> putTitle(
            @Path("account_id") String accountId,
            @Path("year") int year,
            @Path("month") int month,
            @Path("day") int day,
            @Path("schedule_id") int scheduleId,
            @Field("token") String token,
            @Field("title") String title
    );

    @FormUrlEncoded
    @PUT(BASE_URL + "/{year}/{month}/{day}/{schedule_id}")
    Call<String> putBookId(
            @Path("account_id") String accountId,
            @Path("year") int year,
            @Path("month") int month,
            @Path("day") int day,
            @Path("schedule_id") int scheduleId,
            @Field("token") String token,
            @Field("book_id") int bookId
    );

}