package com.rthoni.camotion.dataaccess;

import com.luticate.utils.business.LuPromise;
import com.luticate.utils.business.LuRequest;
import com.luticate.utils.dataaccess.LuDataAccess;
import com.luticate.utils.dbo.LuDataAccessConfigDbo;
import com.luticate.utils.dbo.LuVoidDbo;
import com.rthoni.camotion.dbo.CommandDbo;

import java.util.HashMap;

/**
 * Created by robin on 12/3/15.
 */
public class CommandsDataAccess extends LuDataAccess {

    public static LuPromise<CommandDbo.MultipleCommandDbo> getAll(LuDataAccessConfigDbo config, int page, int perPage)
    {
        HashMap<String, String> params = new HashMap<>();
        params.put("page", "" + page);
        params.put("perPage", "" + perPage);
        return LuRequest.get(config, CommandDbo.MultipleCommandDbo.class, "/api/commands", params);
    }

    public static LuPromise<LuVoidDbo> exec(LuDataAccessConfigDbo config, int id)
    {
        return LuRequest.post(config, LuVoidDbo.class, "/api/commands/" + id + "/exec");
    }
}
