Package com.fitbit.api

Examples of com.fitbit.api.FitbitAPIException


        Response res = httpGet(url, true);
        throwExceptionIfError(res);
        try {
            return Activity.constructActivity(res.asJSONObject());
        } catch (JSONException e) {
            throw new FitbitAPIException("Error retrieving activity: " + e, e);
        }
    }
View Full Code Here


        // Example: POST /1/user/-/activities/favorite/123.json
        String url = APIUtil.contextualizeUrl(getApiBaseUrl(), getApiVersion(), "/user/-/activities/favorite/" + activityId, APIFormat.JSON);
        try {
            httpPost(url, null, true);
        } catch (Exception e) {
            throw new FitbitAPIException("Error adding favorite activity: " + e, e);
        }
    }
View Full Code Here

        // Example: DELETE /1/user/-/activities/favorite/123.json
        String url = APIUtil.contextualizeUrl(getApiBaseUrl(), getApiVersion(), "/user/-/activities/favorite/" + activityId, APIFormat.JSON);
        try {
            httpDelete(url, true);
        } catch (Exception e) {
            throw new FitbitAPIException("Error deleting favorite activity: " + e, e);
        }

    }
View Full Code Here

        Response response = httpPost(url, params.toArray(new PostParameter[params.size()]), true);

        try {
            return new Food(response.asJSONObject().getJSONObject("food"));
        } catch (JSONException e) {
            throw new FitbitAPIException("Error parsing json response to Food object: ", e);
        }
    }
View Full Code Here

        String url = APIUtil.contextualizeUrl(getApiBaseUrl(), getApiVersion(), "/foods/" + foodId, APIFormat.JSON);
        Response res = httpGet(url, true);
        try {
            return new Food(res.asJSONObject().getJSONObject("food"));
        } catch (JSONException e) {
            throw new FitbitAPIException("Error retrieving food details: " + e, e);
        }
    }
View Full Code Here

        Response res;
        try {
            res = httpPost(url, params.toArray(new PostParameter[params.size()]), true);
        } catch (Exception e) {
            throw new FitbitAPIException("Error creating food log entry: " + e, e);
        }
        if (res.getStatusCode() != HttpServletResponse.SC_CREATED) {
            throw new FitbitAPIException("Error creating activity: " + res.getStatusCode());
        }
        try {
            return new FoodLog(res.asJSONObject().getJSONObject("foodLog"));
        } catch (JSONException e) {
            throw new FitbitAPIException("Error creating food log entry: " + e, e);
        }
    }
View Full Code Here

        // Example: DELETE /1/user/-/food/log/123.json
        String url = APIUtil.contextualizeUrl(getApiBaseUrl(), getApiVersion(), "/user/-/foods/log/" + foodLogId, APIFormat.JSON);
        try {
            httpDelete(url, true);
        } catch (Exception e) {
            throw new FitbitAPIException("Error deleting food log entry: " + e, e);
        }
    }
View Full Code Here

        // Example: POST /1/user/-/food/log/favorite/123.json
        String url = APIUtil.contextualizeUrl(getApiBaseUrl(), getApiVersion(), "/user/-/foods/log/favorite/" + foodId, APIFormat.JSON);
        try {
            httpPost(url, null, true);
        } catch (Exception e) {
            throw new FitbitAPIException("Error adding favorite food: " + e, e);
        }
    }
View Full Code Here

        // Example: DELETE /1/user/-/food/log/favorite/123.json
        String url = APIUtil.contextualizeUrl(getApiBaseUrl(), getApiVersion(), "/user/-/foods/log/favorite/" + foodId, APIFormat.JSON);
        try {
            httpDelete(url, true);
        } catch (Exception e) {
            throw new FitbitAPIException("Error deleting favorite food: " + e, e);
        }

    }
View Full Code Here

        Response res = httpGet(url, true);
        throwExceptionIfError(res);
        try {
            return Meal.constructMeals(res.asJSONObject().getJSONArray("meals"));
        } catch (JSONException e) {
            throw new FitbitAPIException(e.getMessage() + ": " + res.asString(), e);
        }
    }
View Full Code Here

TOP

Related Classes of com.fitbit.api.FitbitAPIException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.