package com.mediafire.sdk.api; import com.mediafire.sdk.MFApiException; import com.mediafire.sdk.MFException; import com.mediafire.sdk.MFSessionNotStartedException; import com.mediafire.sdk.MediaFire; import com.mediafire.sdk.api.responses.*; import com.mediafire.sdk.requests.ApiPostRequest; import java.util.LinkedHashMap; /** * http://www.mediafire.com/developers/core_api/1.3/getting_started/ * @see <a href="http://www.mediafire.com/developers/core_api/1.3/getting_started/">MediaFire Developer Portal</a> */ public class UserApi { public UserApi() { // no instantiation, utility class } /** * Returns the URL of the operating user's avatar image. * * @param mediaFire an instance of MediaFire which has a session in progress * @param requestParams a LinkedHashMap of required and optional parameters * @param apiVersion version of the api to call e.g. 1.0, 1.1, 1.2 * @param classOfT the .class file passed which will be used to parse the api JSON response using Gson (must extend ApiResponse) * @return an instance of {@param classOfT} * @throws com.mediafire.sdk.MFException if an exception occurred * @throws MFApiException, MFSessionNotStartedException if there was an api error */ public static <T extends ApiResponse> T getAvatar(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException { ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/user/get_avatar.php", requestParams); return mediaFire.doApiRequest(apiPostRequest, classOfT); } /** * Save a copy of an image file, or a remote image, to serve as the operating user's avatar. * * @param mediaFire an instance of MediaFire which has a session in progress * @param requestParams a LinkedHashMap of required and optional parameters * @param apiVersion version of the api to call e.g. 1.0, 1.1, 1.2 * @param classOfT the .class file passed which will be used to parse the api JSON response using Gson (must extend ApiResponse) * @return an instance of {@param classOfT} * @throws com.mediafire.sdk.MFException if an exception occurred * @throws MFApiException, MFSessionNotStartedException if there was an api error */ public static <T extends ApiResponse> T setAvatar(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException { ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/user/set_avatar.php", requestParams); return mediaFire.doApiRequest(apiPostRequest, classOfT); } /** * Returns a list of the user's personal information. * * @param mediaFire an instance of MediaFire which has a session in progress * @param requestParams a LinkedHashMap of required and optional parameters * @param apiVersion version of the api to call e.g. 1.0, 1.1, 1.2 * @param classOfT the .class file passed which will be used to parse the api JSON response using Gson (must extend ApiResponse) * @return an instance of {@param classOfT} * @throws com.mediafire.sdk.MFException if an exception occurred * @throws MFApiException, MFSessionNotStartedException if there was an api error */ public static <T extends ApiResponse> T getInfo(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException { ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/user/get_info.php", requestParams); return mediaFire.doApiRequest(apiPostRequest, classOfT); } /** * Returns a list of the user's account settings. * * @param mediaFire an instance of MediaFire which has a session in progress * @param requestParams a LinkedHashMap of required and optional parameters * @param apiVersion version of the api to call e.g. 1.0, 1.1, 1.2 * @param classOfT the .class file passed which will be used to parse the api JSON response using Gson (must extend ApiResponse) * @return an instance of {@param classOfT} * @throws com.mediafire.sdk.MFException if an exception occurred * @throws MFApiException, MFSessionNotStartedException if there was an api error */ public static <T extends ApiResponse> T getSettings(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException { ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/user/get_settings.php", requestParams); return mediaFire.doApiRequest(apiPostRequest, classOfT); } /** * Set user preferences. * * @param mediaFire an instance of MediaFire which has a session in progress * @param requestParams a LinkedHashMap of required and optional parameters * @param apiVersion version of the api to call e.g. 1.0, 1.1, 1.2 * @param classOfT the .class file passed which will be used to parse the api JSON response using Gson (must extend ApiResponse) * @return an instance of {@param classOfT} * @throws com.mediafire.sdk.MFException if an exception occurred * @throws MFApiException, MFSessionNotStartedException if there was an api error */ public static <T extends ApiResponse> T setSettings(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException { ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/user/set_settings.php", requestParams); return mediaFire.doApiRequest(apiPostRequest, classOfT); } /** * Causes an existing action token to immediately expire. * * @param mediaFire an instance of MediaFire which has a session in progress * @param requestParams a LinkedHashMap of required and optional parameters * @param apiVersion version of the api to call e.g. 1.0, 1.1, 1.2 * @param classOfT the .class file passed which will be used to parse the api JSON response using Gson (must extend ApiResponse) * @return an instance of {@param classOfT} * @throws com.mediafire.sdk.MFException if an exception occurred * @throws MFApiException, MFSessionNotStartedException if there was an api error */ public static <T extends ApiResponse> T destroyActionToken(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException { ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/user/destroy_action_token.php", requestParams); return mediaFire.doApiRequest(apiPostRequest, classOfT); } /** * Generates a session token with a life of 10 minutes to be used in upcoming API requests. * * @param mediaFire an instance of MediaFire which has a session in progress * @param requestParams a LinkedHashMap of required and optional parameters * @param apiVersion version of the api to call e.g. 1.0, 1.1, 1.2 * @param classOfT the .class file passed which will be used to parse the api JSON response using Gson (must extend ApiResponse) * @return an instance of {@param classOfT} * @throws com.mediafire.sdk.MFException if an exception occurred * @throws MFApiException, MFSessionNotStartedException if there was an api error */ public static <T extends ApiResponse> T getSessionToken(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException { ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/user/get_session_token.php", requestParams); return mediaFire.doApiRequest(apiPostRequest, classOfT); } /** * Generates a temporary action token that is specific to one type of request specified by the parameter type. * Action Token is to be used in place of a session token in subsequent API requests. * Because the session token lasts only 10 minutes, and the session token version 2 requires a signature for every call, * Action Token cannot be used in certain operations. The Action Token can then be sent in lieu of the session token * for authentication. It can also be destroyed after its use by calling user/destroy_action_token. * * @param mediaFire an instance of MediaFire which has a session in progress * @param requestParams a LinkedHashMap of required and optional parameters * @param apiVersion version of the api to call e.g. 1.0, 1.1, 1.2 * @param classOfT the .class file passed which will be used to parse the api JSON response using Gson (must extend ApiResponse) * @return an instance of {@param classOfT} * @throws com.mediafire.sdk.MFException if an exception occurred * @throws MFApiException, MFSessionNotStartedException if there was an api error */ public static <T extends ApiResponse> T getActionToken(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException { ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/user/get_action_token.php", requestParams); return mediaFire.doApiRequest(apiPostRequest, classOfT); } /** * Returns the HTML format of the MediaFire Terms of Service and its revision number, date, whether the * user has accepted it not not, and the acceptance token (if the user has not accepted the latest terms). * * @param mediaFire an instance of MediaFire which has a session in progress * @param requestParams a LinkedHashMap of required and optional parameters * @param apiVersion version of the api to call e.g. 1.0, 1.1, 1.2 * @param classOfT the .class file passed which will be used to parse the api JSON response using Gson (must extend ApiResponse) * @return an instance of {@param classOfT} * @throws com.mediafire.sdk.MFException if an exception occurred * @throws MFApiException, MFSessionNotStartedException if there was an api error */ public static <T extends ApiResponse> T fetchTermsOfService(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException { ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/user/fetch_tos.php", requestParams); return mediaFire.doApiRequest(apiPostRequest, classOfT); } /** * Returns an array of limit-related statuses for the user. * * @param mediaFire an instance of MediaFire which has a session in progress * @param requestParams a LinkedHashMap of required and optional parameters * @param apiVersion version of the api to call e.g. 1.0, 1.1, 1.2 * @param classOfT the .class file passed which will be used to parse the api JSON response using Gson (must extend ApiResponse) * @return an instance of {@param classOfT} * @throws com.mediafire.sdk.MFException if an exception occurred * @throws MFApiException, MFSessionNotStartedException if there was an api error */ public static <T extends ApiResponse> T getLimits(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException { ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/user/get_limits.php", requestParams); return mediaFire.doApiRequest(apiPostRequest, classOfT); } }