com.orgyflame.springtelegrambotapi.api.method.stickers.GetStickerSet Maven / Gradle / Ivy
package com.orgyflame.springtelegrambotapi.api.method.stickers;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import com.orgyflame.springtelegrambotapi.api.method.BotApiMethod;
import com.orgyflame.springtelegrambotapi.api.object.ApiResponse;
import com.orgyflame.springtelegrambotapi.api.object.stickers.StickerSet;
import com.orgyflame.springtelegrambotapi.exceptions.TelegramApiRequestException;
import com.orgyflame.springtelegrambotapi.exceptions.TelegramApiValidationException;
import lombok.*;
import java.io.IOException;
/**
* @author Ruben Bermudez
* @version 1.0
* Use this method to get a sticker set. On success, a StickerSet object is returned.
*/
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class GetStickerSet extends BotApiMethod {
private static final String PATH = "getStickerSet";
private static final String NAME_FIELD = "name";
@JsonProperty(NAME_FIELD)
@NonNull
private String name; ///< Name of the sticker set
@Override
public String getMethod() {
return PATH;
}
@Override
public StickerSet deserializeResponse(String answer) throws TelegramApiRequestException {
try {
ApiResponse result = OBJECT_MAPPER.readValue(answer,
new TypeReference>() {
});
if (result.getOk()) {
return result.getResult();
} else {
throw new TelegramApiRequestException("Error getting sticker set", result);
}
} catch (IOException e) {
throw new TelegramApiRequestException("Unable to deserialize response", e);
}
}
@Override
public void validate() throws TelegramApiValidationException {
if (name == null || name.isEmpty()) {
throw new TelegramApiValidationException("Name can't be null", this);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy