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.rthoni.camotion.dbo.SensorDbo;
import com.rthoni.camotion.dbo.SensorValueDbo;

import java.util.HashMap;

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

    public static LuPromise<SensorDbo.MultipleSensorDbo> 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, SensorDbo.MultipleSensorDbo.class, "/api/sensors", params);
    }

    public static LuPromise<SensorValueDbo> getValue(LuDataAccessConfigDbo config, int id)
    {
        return LuRequest.post(config, SensorValueDbo.class, "/api/sensors/" + id + "/value");
    }
}
