com.arcao.geocaching.api.impl
Class LiveGeocachingApi

java.lang.Object
  extended by com.arcao.geocaching.api.GeocachingApi
      extended by com.arcao.geocaching.api.impl.LiveGeocachingApi

public class LiveGeocachingApi
extends GeocachingApi

Implementation of Life Geocaching Api provided by Groundspeak. To use this class you need consumer and license key, ask Groundspeak for them.

Note: Most of methods is limited from Groundspeak side. See Live Geocaching Api agreement.

Some limits for Premium User:

Author:
arcao

Field Summary
protected static String BASE_URL
           
protected  String consumerKey
           
protected  String licenseKey
           
 
Fields inherited from class com.arcao.geocaching.api.GeocachingApi
session
 
Constructor Summary
LiveGeocachingApi(String consumerKey, String licenseKey)
          Create a new instance of LiveGeocachingApi with specified consumer key and license key.
 
Method Summary
protected  JsonReader callGet(String function)
           
protected  JsonReader callPost(String function, String postBody)
           
 void closeSession()
          Close current used session
 CacheLog createFieldNoteAndPublish(String cacheCode, LogType logType, Date dateLogged, String note, boolean publish, ImageData imageData, boolean favoriteThisCache)
          Create field note and publish them or store them to list of Field notes on Geocaching site.
 List<CacheLog> getCacheLogsByCacheCode(String cacheCode, int startIndex, int maxPerPage)
          Get a list of cache logs in given cache.
 List<SimpleGeocache> getMoreGeocaches(boolean isLite, int startIndex, int maxPerPage, int geocacheLogCount, int trackableLogCount)
           
 Trackable getTrackable(String trackableCode, int trackableLogCount)
          Get a trackable object for given trackable code.
 List<Trackable> getTrackablesByCacheCode(String cacheCode, int startIndex, int maxPerPage, int trackableLogCount)
          Get a list of trackables which is currently placed in a cache.
 UserProfile getYourUserProfile(boolean favoritePointData, boolean geocacheData, boolean publicProfileData, boolean souvenirData, boolean trackableData)
          Get a information about user
protected  void checkError(JsonReader r)
           
 boolean isSessionValid()
          Check if current used session is still valid
protected  String maskPassword(String input)
           
 void openSession(String userName, String password)
          Open a new session and log-in user
 List<SimpleGeocache> searchForGeocaches(boolean isLite, int maxPerPage, int geocacheLogCount, int trackableLogCount, Filter[] filters)
          Search for geocaches and return list of found.
 
Methods inherited from class com.arcao.geocaching.api.GeocachingApi
createFieldNoteAndPublish, getCache, getCacheSimple, getSession, openSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_URL

protected static final String BASE_URL
See Also:
Constant Field Values

consumerKey

protected final String consumerKey

licenseKey

protected final String licenseKey
Constructor Detail

LiveGeocachingApi

public LiveGeocachingApi(String consumerKey,
                         String licenseKey)
Create a new instance of LiveGeocachingApi with specified consumer key and license key.

Parameters:
consumerKey - consumer key
licenseKey - license key
Method Detail

openSession

public void openSession(String userName,
                        String password)
                 throws GeocachingApiException
Description copied from class: GeocachingApi
Open a new session and log-in user

Specified by:
openSession in class GeocachingApi
Parameters:
userName - user name
password - password
Throws:
GeocachingApiException - If Geocaching API error occurs

closeSession

public void closeSession()
Description copied from class: GeocachingApi
Close current used session

Specified by:
closeSession in class GeocachingApi

isSessionValid

public boolean isSessionValid()
Description copied from class: GeocachingApi
Check if current used session is still valid

Specified by:
isSessionValid in class GeocachingApi
Returns:
true if is valid otherwise false

searchForGeocaches

public List<SimpleGeocache> searchForGeocaches(boolean isLite,
                                               int maxPerPage,
                                               int geocacheLogCount,
                                               int trackableLogCount,
                                               Filter[] filters)
                                        throws GeocachingApiException
Description copied from class: GeocachingApi
Search for geocaches and return list of found.

Specified by:
searchForGeocaches in class GeocachingApi
Parameters:
isLite - true if return a basic information about caches or fales for full information about caches
maxPerPage - count of caches to get
geocacheLogCount - count of logs to get
trackableLogCount - count of trackables to get
filters - used filters while searching
Returns:
list of found caches
Throws:
GeocachingApiException - If error occurs during searching caches

getMoreGeocaches

public List<SimpleGeocache> getMoreGeocaches(boolean isLite,
                                             int startIndex,
                                             int maxPerPage,
                                             int geocacheLogCount,
                                             int trackableLogCount)
                                      throws GeocachingApiException
Specified by:
getMoreGeocaches in class GeocachingApi
Parameters:
isLite - true if return a basic information about caches or fales for full information about caches
startIndex - count of caches to skip
maxPerPage - count of caches to get
geocacheLogCount - count of caches to get
trackableLogCount - count of trackables to get
Returns:
list of found caches
Throws:
GeocachingApiException - If error occurs during searching caches

getTrackable

public Trackable getTrackable(String trackableCode,
                              int trackableLogCount)
                       throws GeocachingApiException
Description copied from class: GeocachingApi
Get a trackable object for given trackable code. This method works for public trackable code and also for private (secret) trackable code.

Specified by:
getTrackable in class GeocachingApi
Parameters:
trackableCode - trackable code
trackableLogCount - count of trackable logs to get
Returns:
information about trackable
Throws:
GeocachingApiException - If error occurs during getting information

getTrackablesByCacheCode

public List<Trackable> getTrackablesByCacheCode(String cacheCode,
                                                int startIndex,
                                                int maxPerPage,
                                                int trackableLogCount)
                                         throws GeocachingApiException
Description copied from class: GeocachingApi
Get a list of trackables which is currently placed in a cache.

Specified by:
getTrackablesByCacheCode in class GeocachingApi
Parameters:
cacheCode - cache code
startIndex - count of trackables to skip
maxPerPage - count of trackables to get
trackableLogCount - count of trackable logs to get
Returns:
list of trackables
Throws:
GeocachingApiException - If error occurs during getting information

getCacheLogsByCacheCode

public List<CacheLog> getCacheLogsByCacheCode(String cacheCode,
                                              int startIndex,
                                              int maxPerPage)
                                       throws GeocachingApiException
Description copied from class: GeocachingApi
Get a list of cache logs in given cache.

Specified by:
getCacheLogsByCacheCode in class GeocachingApi
Parameters:
cacheCode - cache code
startIndex - count of logs to skip
maxPerPage - count of logs to get
Returns:
list of cache logs
Throws:
GeocachingApiException - If error occurs during getting information

createFieldNoteAndPublish

public CacheLog createFieldNoteAndPublish(String cacheCode,
                                          LogType logType,
                                          Date dateLogged,
                                          String note,
                                          boolean publish,
                                          ImageData imageData,
                                          boolean favoriteThisCache)
                                   throws GeocachingApiException
Description copied from class: GeocachingApi
Create field note and publish them or store them to list of Field notes on Geocaching site.

Specified by:
createFieldNoteAndPublish in class GeocachingApi
Parameters:
cacheCode - geocache which can own this field note
logType - type of log
dateLogged - when cache was found
note - text of field note
publish - true if publish log to cache or false to add to Field note list on Geocaching site
imageData - data about image to publish together or null to not publish any image
favoriteThisCache - true if add cache to favorite list otherwise false
Returns:
cache log
Throws:
GeocachingApiException - If error occurs during sending field note

getYourUserProfile

public UserProfile getYourUserProfile(boolean favoritePointData,
                                      boolean geocacheData,
                                      boolean publicProfileData,
                                      boolean souvenirData,
                                      boolean trackableData)
                               throws GeocachingApiException
Description copied from class: GeocachingApi
Get a information about user

Specified by:
getYourUserProfile in class GeocachingApi
Parameters:
favoritePointData - include favorites points
geocacheData - include information about caches
publicProfileData - include public profile information
souvenirData - include souvenirs
trackableData - include trackables
Returns:
UserProfile object with selected information
Throws:
GeocachingApiException - If error occurs during getting information

checkError

protected void checkError(JsonReader r)
                   throws GeocachingApiException,
                          IOException
Throws:
GeocachingApiException
IOException

callGet

protected JsonReader callGet(String function)
                      throws GeocachingApiException
Throws:
GeocachingApiException

callPost

protected JsonReader callPost(String function,
                              String postBody)
                       throws GeocachingApiException
Throws:
GeocachingApiException

maskPassword

protected String maskPassword(String input)


Copyright © 2012. All Rights Reserved.