Package com.fitbit.api

Examples of com.fitbit.api.FitbitAPIException


    public void getTokenCredentials(LocalUserDetail user) throws FitbitAPIException {
        // Get cached resource credentials:
        APIResourceCredentials resourceCredentials = getResourceCredentialsByUser(user);
        if (resourceCredentials == null) {
            throw new FitbitAPIException("User " + user.getUserId() + " does not have resource credentials. Need to grant authorization first.");
        }

        String tempToken = resourceCredentials.getTempToken();
        String tempTokenSecret = resourceCredentials.getTempTokenSecret();
        if (tempToken == null || tempTokenSecret == null) {
            throw new FitbitAPIException("Resource credentials for resource " + user.getUserId() + " are in an invalid state: temporary token or secret is null.");
        }

        // Get and save token credentials:
        AccessToken accessToken = client.getOAuthAccessToken(tempToken, tempTokenSecret, resourceCredentials.getTempTokenVerifier());
        resourceCredentials.setAccessToken(accessToken.getToken());
View Full Code Here


     * @param subscriptionId ID associated with subscription
     * @return SubscriptionDetail
     */
    public SubscriptionDetail subscribe(String subscriberId, LocalUserDetail user, APICollectionType collectionType, final String subscriptionId) throws FitbitAPIException {
        if (null == subscriptionStore) {
            throw new FitbitAPIException("Can not deal with subscriptions without a place to store information about them.");
        }

        // This example application only allows a single subscription per
        // (local) user. We use the user's ID as the subscription ID to avoid
        // having to maintain a mapping.
View Full Code Here

     * @param collectionType
     * @param subscriptionId
     */
    public void unsubscribe(String subscriberId, LocalUserDetail user, APICollectionType collectionType, final String subscriptionId) throws FitbitAPIException {
        if (null == subscriptionStore) {
            throw new FitbitAPIException("Can not deal with subscriptions without a place to store information about them.");
        }

        // This example application only allows a single subscription per
        // (local) user. We use the user's ID as the subscription ID to avoid
        // having to maintain a mapping.
View Full Code Here

                } else {
                    log.info("There is no cached version of entity " + cacheKeyWithPlaceholder);
                }
            }
        } catch (IOException e) {
            throw new FitbitAPIException("Notification stream is malformed: " + e, e);
        } catch (JSONException e) {
            throw new FitbitAPIException("Unable to parse update message: " + e, e);
        }
    }
View Full Code Here

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

    public static List<FoodLog> constructFoodLogList(Response res, String arrayName) throws FitbitAPIException {
        try {
            JSONObject json = res.asJSONObject();
            return jsonArrayToFoodLogList(json.getJSONArray(arrayName));
         } catch (JSONException e) {
            throw new FitbitAPIException(e.getMessage() + ':' + res.asString(), e);
        }
    }
View Full Code Here

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

    public static List<Food> constructFoodList(Response res, String arrayName) throws FitbitAPIException {
        try {
            JSONObject json = res.asJSONObject();
            return jsonArrayToFoodList(json.getJSONArray(arrayName));
        } catch (JSONException e) {
            throw new FitbitAPIException(e.getMessage() + ':' + res.asString(), e);
        }
    }
View Full Code Here

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

    public static List<LoggedActivityReference> constructLoggedActivityReferenceList(Response res) throws FitbitAPIException {
        try {
            return jsonArrayToLoggedActivityReferenceList(res.asJSONArray());
         } 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.