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 NotificationsApi {
private NotificationsApi() {
// no instantiation, utility class only
}
/**
* Gets and clears a specified number of the most recent cache-only notifications for the current 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 getCache(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/notifications/get_cache.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Gets the number of cache-only notifications for the current 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 peekCache(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/notifications/peek_cache.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Sends a generic message with a list of file and folder keys to one or more contacts.
*
* @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 sendMessage(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/notifications/send_message.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
*
* @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 sendNotification(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/notifications/send_notification.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
}