Examples of FitbitAPIException


Examples of com.fitbit.api.FitbitAPIException

     */
    public JSONArray asJSONArray() throws FitbitAPIException {
        try {
            return new JSONArray(asString());
        } catch (JSONException jsone) {
            throw new FitbitAPIException(jsone.getMessage() + ':' + responseAsString, jsone);
        }
    }
View Full Code Here

Examples of com.fitbit.api.FitbitAPIException

        try {
            SleepSummary summary = new SleepSummary(res.asJSONObject().getJSONObject("summary"));
            List<SleepLog> sleepLogs = jsonArrayToSleepLogList(res.asJSONObject().getJSONArray("sleep"));
            return new Sleep(summary, sleepLogs);
         } catch (JSONException e) {
            throw new FitbitAPIException(e.getMessage() + ':' + res.asString(), e);
        }
    }
View Full Code Here

Examples of com.fitbit.api.FitbitAPIException

    public static List<ActivityReference> constructActivityReferenceList(Response res) throws FitbitAPIException {
        try {
            return jsonArrayToActivityReferenceList(res.asJSONArray());
         } catch (JSONException e) {
            throw new FitbitAPIException(e.getMessage() + ':' + res.asString(), e);
        }
    }
View Full Code Here

Examples of com.fitbit.api.FitbitAPIException

    public static List<FoodUnit> constructFoodUnitList(Response res) throws FitbitAPIException {
        try {
            return jsonArrayToFoodUnitList(res.asJSONArray());
        } catch (JSONException e) {
           throw new FitbitAPIException(e.getMessage() + ':' + res.asString(), e);
       }
    }
View Full Code Here

Examples of com.fitbit.api.FitbitAPIException

            JSONObject rateLimitStatus = res.asJSONObject().getJSONObject("rateLimitStatus");
            remainingHits = rateLimitStatus.getInt("remainingHits");
            hourlyLimit = rateLimitStatus.getInt("hourlyLimit");
            resetTime = ISODateTimeFormat.dateTime().parseDateTime(rateLimitStatus.getString("resetTime"));
         } catch (JSONException e) {
            throw new FitbitAPIException(e.getMessage() + ':' + res.asString(), e);
        }
    }
View Full Code Here

Examples of com.fitbit.api.FitbitAPIException

        Response res = httpGet(url, true);
        throwExceptionIfError(res);
        try {
            return Achievements.constructAchievements(res);
        } catch (JSONException e) {
            throw new FitbitAPIException("Error parsing achievements: " + e, e);
        }
    }
View Full Code Here

Examples of com.fitbit.api.FitbitAPIException

        Response res = httpGet(url, true);
        throwExceptionIfError(res);
        try {
            return new LifetimeAchievements(res.asJSONObject().getJSONObject("lifetime"));
        } catch (JSONException e) {
            throw new FitbitAPIException("Error parsing lifetime achievements: " + e, e);
        }
    }
View Full Code Here

Examples of com.fitbit.api.FitbitAPIException

        Response res;
        try {
            res = httpPost(url, params.toArray(new PostParameter[params.size()]), true);
        } catch (Exception e) {
            throw new FitbitAPIException("Error creating activity: " + e, e);
        }

        if (res.getStatusCode() != HttpServletResponse.SC_CREATED) {
            throw new FitbitAPIException("Error creating activity: " + res.getStatusCode());
        }
        try {
            return new ActivityLog(res.asJSONObject().getJSONObject("activityLog"));
        } catch (JSONException e) {
            throw new FitbitAPIException("Error creating activity: " + e, e);
        }
    }
View Full Code Here

Examples of com.fitbit.api.FitbitAPIException

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

Examples of com.fitbit.api.FitbitAPIException

        Response res = httpGet(url, true);
        throwExceptionIfError(res);
        try {
            return ActivityCategory.jsonArrayToActivityCategoryList(res.asJSONObject().getJSONArray("categories"));
        } catch (JSONException e) {
            throw new FitbitAPIException("Error retrieving activity: " + e, e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.