add getFile to AbsSender in order to get the file path

This commit is contained in:
Marcel Caspar 2016-03-25 19:15:11 +01:00
parent cc38a3c149
commit d30f77f6f2
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

@ -90,6 +90,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();