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;
/**
*
* @see <a href="http://www.mediafire.com/developers/core_api/1.3/getting_started/">MediaFire Developer Portal</a>
*/
public class DeviceApi {
private DeviceApi() {
// no instantiation, utility class
}
/**
* Returns the list of all files and folders with revisions greater than the passed parameter revision and less
* than or equal to the next 500-multiplier. For example, if revision=1211, then all files and folders with
* revision greater than 1211 and less than or equal 1500 are returned.
*
* @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 getChanges(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/get_changes.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Returns various information about the status of a device specified by device_id.
*
* @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 getStatus(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/get_status.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Empties out the content of the trash can. If the trash has too many items, then the API will return
* immediately with the property asynchronous=yes and the operation will be performed in the background.
*
* @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 emptyTrash(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/empty_trash.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Grants the current user read permissions for the specified resource.
*
* @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 followResource(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/follow_resource.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Returns a list of all shared resources from a user's contact with recent changes since revision and less than or
* equal to the next 500-multiplier. For example, if revision=1211, then all files and folders with revision greater
* than 1211 and less than or equal 1500 are returned.
*
* @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 getForeignChanges(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/get_foreign_changes.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Gets information about resources shared with 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 getForeignResources(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/get_foreign_resources.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 getPatch(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/get_patch.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* When an updated version of a large file needs to be synced from the cloud to a client's system, a significant
* amount of bandwidth is utilized. With device/get_patch you can greatly reduce sync and bandwidth overhead
* by allowing the caller to download a smaller set of incremental differentials which can be applied, in sequence,
* to a file until the file is current. Because patch files are smaller, less bandwidth and time are required.
*
* @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 getResourceShares(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/get_resource_shares.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Returns the trash can folder data and the list of immediate files and folders in the trash can.
* Contents of subfolders in the trash can will not be returned.
*
* @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 getTrash(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/get_trash.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Returns the list of patches for a file that belongs to the session user for a certain revision range.
* It will also return the current revision number of the file.
*
* @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 getUpdates(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/get_updates.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Returns a list of files and folders that have been shared with others.
*
* @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 getUserShares(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/get_user_shares.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Requests access to the specified file or folder.
*
* @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 requestForeignResource(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/request_foreign_resource.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Share files and/or folders with specified 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 shareResources(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/share_resources.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Revokes the session user's permissions to a resource shared to the session 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 unfollowResource(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/unfollow_resource.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
/**
* Unshares the specified resource with all contacts or one specified contact.
*
* @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 unshareResources(MediaFire mediaFire, LinkedHashMap<String, Object> requestParams, String apiVersion, Class<T> classOfT) throws MFException, MFApiException, MFSessionNotStartedException {
ApiPostRequest apiPostRequest = new ApiPostRequest("/api/" + apiVersion + "/device/unshare_resources.php", requestParams);
return mediaFire.doApiRequest(apiPostRequest, classOfT);
}
}