|
| 1 | +package org.telegram.telegrambots.meta.api.methods.payments.star; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 4 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 5 | +import lombok.EqualsAndHashCode; |
| 6 | +import lombok.Getter; |
| 7 | +import lombok.RequiredArgsConstructor; |
| 8 | +import lombok.Setter; |
| 9 | +import lombok.ToString; |
| 10 | +import lombok.experimental.SuperBuilder; |
| 11 | +import lombok.extern.jackson.Jacksonized; |
| 12 | +import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethod; |
| 13 | +import org.telegram.telegrambots.meta.api.objects.payments.star.StarTransactions; |
| 14 | +import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException; |
| 15 | +import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException; |
| 16 | + |
| 17 | +/** |
| 18 | + * @author Ruben Bermudez |
| 19 | + * @version 7.5 |
| 20 | + * |
| 21 | + * Returns the bot's Telegram Star transactions in chronological order. |
| 22 | + * On success, returns a StarTransactions object. |
| 23 | + */ |
| 24 | +@EqualsAndHashCode(callSuper = false) |
| 25 | +@Getter |
| 26 | +@Setter |
| 27 | +@ToString |
| 28 | +@RequiredArgsConstructor |
| 29 | +@SuperBuilder |
| 30 | +@Jacksonized |
| 31 | +@JsonIgnoreProperties(ignoreUnknown = true) |
| 32 | +public class GetStarTransactions extends BotApiMethod<StarTransactions> { |
| 33 | + public static final String PATH = "getStarTransactions"; |
| 34 | + |
| 35 | + private static final String OFFSET_FIELD = "offset"; |
| 36 | + private static final String LIMIT_FIELD = "limit"; |
| 37 | + |
| 38 | + /** |
| 39 | + * Optional |
| 40 | + * Number of transactions to skip in the response |
| 41 | + */ |
| 42 | + @JsonProperty(OFFSET_FIELD) |
| 43 | + private Integer offset; |
| 44 | + /** |
| 45 | + * Optional |
| 46 | + * The maximum number of transactions to be retrieved. |
| 47 | + * Values between 1-100 are accepted. |
| 48 | + * Defaults to 100. |
| 49 | + */ |
| 50 | + @JsonProperty(LIMIT_FIELD) |
| 51 | + private Integer limit; |
| 52 | + |
| 53 | + @Override |
| 54 | + public StarTransactions deserializeResponse(String answer) throws TelegramApiRequestException { |
| 55 | + return deserializeResponse(answer, StarTransactions.class); |
| 56 | + } |
| 57 | + |
| 58 | + @Override |
| 59 | + public String getMethod() { |
| 60 | + return PATH; |
| 61 | + } |
| 62 | + |
| 63 | + @Override |
| 64 | + public void validate() throws TelegramApiValidationException { |
| 65 | + if (limit != null && (limit > 100 || limit < 0)) { |
| 66 | + throw new TelegramApiValidationException("Limit parameters must be between 0 and 100", this); |
| 67 | + } |
| 68 | + } |
| 69 | +} |
0 commit comments