Merge pull request #18 from Clevero/add-api-method-getFile-to-AbsSender

add getFile to AbsSender in order to get the file path
This commit is contained in:
Ruben Bermudez 2016-04-01 01:07:07 +02:00
commit dcb58090a4
3 changed files with 13 additions and 2 deletions

View File

@ -21,7 +21,7 @@ import java.io.IOException;
* @date 20 of June of 2015
*/
public class GetFile extends BotApiMethod<File> {
public static final String PATH = "getfield";
public static final String PATH = "getFile";
public static final String FILEID_FIELD = "file_id";
private String fileId; ///< File identifier to get info about

View File

@ -22,7 +22,7 @@ public class File implements IBotApiObject {
public static final String FILE_SIZE_FIELD = "file_size";
@JsonProperty(FILE_SIZE_FIELD)
private Integer fileSize; ///< Optional. File size, if known
public static final String FILE_PATH_FIELD = "first_name";
public static final String FILE_PATH_FIELD = "file_path";
@JsonProperty(FILE_PATH_FIELD)
private String filePath; ///< Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.

View File

@ -107,6 +107,17 @@ public abstract class AbsSender {
return (UserProfilePhotos) sendApiMethod(getUserProfilePhotos);
}
public File getFile(GetFile getFile) throws TelegramApiException{
if(getFile == null){
throw new TelegramApiException("Parameter getFile can not be null");
}
else if(getFile.getFileId() == null){
throw new TelegramApiException("Attribute file_id in parameter getFile can not be null");
}
return (File)sendApiMethod(getFile);
}
public User getMe() throws TelegramApiException {
GetMe getMe = new GetMe();