package insat.unotifier.util;

import insat.unotifier.common.Config;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;


public class DeviceFunctions {

    private JSONParser jsonParser;

    // constructor
    public DeviceFunctions() {
        jsonParser = new JSONParser();
    }

    /**
     * Function to Register
     */
    public JSONObject registerUser(Device device) {
        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair(Config.KEY_IDENTIFIANT, device.getIdentifiant()));
        params.add(new BasicNameValuePair(Config.KEY_TOKEN, device.getToken()));
        params.add(new BasicNameValuePair(Config.KEY_TYPE, device.getType()));
        JSONObject json = jsonParser.getJSONFromUrl(Config.URL, params);
        return json;
    }
    public JSONObject registerView(String idMsg) {
        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair(Config.KEY_IDMSG, idMsg));
        JSONObject json = jsonParser.getJSONFromUrl(Config.URL2, params);
        return json;
    }

}
