All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rocks.voss.toniebox.TonieHandler Maven / Gradle / Ivy

There is a newer version: 3.7
Show newest version
package rocks.voss.toniebox;

import org.apache.log4j.Logger;
import rocks.voss.toniebox.beans.toniebox.CreativeTonie;
import rocks.voss.toniebox.beans.toniebox.Household;
import rocks.voss.toniebox.beans.toniebox.Login;
import rocks.voss.toniebox.beans.toniebox.Me;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class TonieHandler {
    private Logger log = Logger.getLogger(getClass().getName());
    final private RequestHandler requestHandler;

    /**
     * Default constructor
     */
    public TonieHandler() {
        requestHandler = new RequestHandler();
    }

    /**
     * Constructor for Proxy usage
     * @param proxySchema http/https
     * @param proxyHost to which proxy host to connect
     * @param proxyPort port on which the proxy listens
     */
    public TonieHandler(String proxySchema, String proxyHost, int proxyPort) {
        requestHandler = new RequestHandler(proxySchema, proxyHost, proxyPort);
    }

    /**
     * Login the toniebox user
     *
     * @param username for your Toniebox Account
     * @param password for your Toniebox Account
     * @throws IOException will be thrown if something goes wrong
     */
    public void login(String username, String password) throws IOException {
        Login loginBean = new Login();
        loginBean.setEmail(username);
        loginBean.setPassword(password);
        requestHandler.Login(loginBean);
    }

    /**
     * This method retieves the households you're in
     *
     * @return list of households
     * @throws IOException will be thrown if something goes wrong
     */
    public List getHouseholds() throws IOException {
        return Arrays.asList(requestHandler.getHouseholds());
    }

    /**
     * This method loads all available Tonies you may want to interact with
     *
     * @param household the household to which the Tonie belongs
     * @return a list of CreativeTonies
     * @throws IOException will be thrown if something goes wrong
     */
    public List getCreativeTonies(Household household) throws IOException {
        return Arrays.asList(requestHandler.getCreativeTonies(household));
    }

    /**
     * This method retrieves your personal information
     *
     * @return personal information
     * @throws IOException will be thrown if something goes wrong
     */
    public Me getMe() throws IOException {
        return requestHandler.getMe();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy