Package com.fitbit.api

Examples of com.fitbit.api.FitbitAPIException


        Response response = httpGet(url, true);
        throwExceptionIfError(response);
        try {
            return FriendStats.jsonArrayToFriendStatsList(response.asJSONObject().getJSONArray("friends"));
        } catch (JSONException e) {
            throw new FitbitAPIException("Error parsing json response to list of FriendStats : ", e);
        }
    }
View Full Code Here


                break;
            case CLIENT:
                quoteTypeToken = "client";
                break;
            default:
                throw new FitbitAPIException(String.format("Illegal quote type '%s'", quotaType));
        }
        String relativePath = "/account/" + quoteTypeToken + "RateLimitStatus";
        String url = APIUtil.contextualizeUrl(getApiBaseUrl(), APIVersion.BETA_1, relativePath, APIFormat.JSON);
        return new ApiRateLimitStatus(httpGet(url, true));
    }
View Full Code Here

        try {
            return new SubscriptionDetail(httpPost(url, null, true).asJSONObject());
        } catch (FitbitAPIException e) {
            throw e;
        } catch (Exception e) {
            throw new FitbitAPIException("Could not create subscription: " + e, e);
        }
    }
View Full Code Here

                ApiSubscription apiSubscription = new ApiSubscription(jsonArray.getJSONObject(i));
                result.add(apiSubscription);
            }
            return result;
        } catch (JSONException e) {
            throw new FitbitAPIException("Error retrieving water: " + e, e);
        }
    }
View Full Code Here

        Response res = httpGet(url, true);
        throwExceptionIfError(res);
        try {
            return Data.jsonArrayToDataList(res.asJSONObject().getJSONArray(resourceType.getResourcePath().substring(1).replace('/', '-')));
        } catch (JSONException e) {
            throw new FitbitAPIException("Error parsing json response to data list : ", e);
        }
    }
View Full Code Here

        Response res = httpGet(url, true);
        throwExceptionIfError(res);
        try {
            return new IntradaySummary(res.asJSONObject(), resourceType);
        } catch (JSONException e) {
            throw new FitbitAPIException("Error parsing json response to IntradaySummary : ", e);
        }
    }
View Full Code Here

        return url;
    }

    public static void throwExceptionIfError(Response res) throws FitbitAPIException {
        if (res.isError()) {
            throw new FitbitAPIException(getErrorMessage(res));
        }
    }
View Full Code Here

        }
    }

    public static void throwExceptionIfError(Response res, int expectedStatusCode) throws FitbitAPIException {
        if (res.getStatusCode() != expectedStatusCode) {
            throw new FitbitAPIException(getErrorMessage(res));
        }
    }
View Full Code Here

        try {
            Response res = httpPost(url, params.toArray(new PostParameter[params.size()]), true);
            return new WeightLog(res.asJSONObject().getJSONObject("weightLog"));
        } catch (FitbitAPIException e) {
            throw new FitbitAPIException("Error logging weight: " + e, e);
        } catch (JSONException e) {
            throw new FitbitAPIException("Error logging weight: " + e, e);
        }
    }
View Full Code Here

        Response res = httpGet(url, true);
        throwExceptionIfError(res);
        try {
            return WeightLog.constructWeightLogList(res.asJSONObject().getJSONArray("weight"));
        } catch (JSONException e) {
            throw new FitbitAPIException("Error retrieving weight: " + e, 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.