Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendGift and getAvailableGifts API #405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions library/src/main/java/com/pengrad/telegrambot/model/Gift.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.pengrad.telegrambot.model;

import java.io.Serializable;
import java.util.Objects;

public class Gift implements Serializable {
private final static long serialVersionUID = 0L;

private String id;
private Sticker sticker;
private Integer star_count;
private Integer total_count;
private Integer remaining_count;

public String id() {
return id;
}

public Sticker sticker() {
return sticker;
}

public Integer starCount() {
return star_count;
}

public Integer totalCount() {
return total_count;
}

public Integer remainingCount() {
return remaining_count;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Gift gift = (Gift) o;
return Objects.equals(id, gift.id) && Objects.equals(sticker, gift.sticker) && Objects.equals(star_count, gift.star_count) && Objects.equals(total_count, gift.total_count) && Objects.equals(remaining_count, gift.remaining_count);
}

@Override
public int hashCode() {
int result = Objects.hashCode(id);
result = 31 * result + Objects.hashCode(sticker);
result = 31 * result + Objects.hashCode(star_count);
result = 31 * result + Objects.hashCode(total_count);
result = 31 * result + Objects.hashCode(remaining_count);
return result;
}

@Override
public String toString() {
return "Gift{" +
"id='" + id + '\'' +
", sticker=" + sticker +
", star_count=" + star_count +
", total_count=" + total_count +
", remaining_count=" + remaining_count +
'}';
}
}
22 changes: 22 additions & 0 deletions library/src/main/java/com/pengrad/telegrambot/model/Gifts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.pengrad.telegrambot.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

public class Gifts implements Serializable {
private final static long serialVersionUID = 0L;

private Gift[] gifts;

public Gift[] gifts() {
return gifts;
}

@Override
public String toString() {
return "GetAvailableGiftsResponse{" +
"gifts=" + Arrays.toString(gifts) +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.pengrad.telegrambot.request;

import com.pengrad.telegrambot.response.GetAvailableGiftsResponse;

public class GetAvailableGifts extends BaseRequest<GetAvailableGifts, GetAvailableGiftsResponse> {
public GetAvailableGifts(Object chatId) {
super(GetAvailableGiftsResponse.class);
add("chat_id", chatId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.pengrad.telegrambot.request;

import com.pengrad.telegrambot.response.BaseResponse;

public class SendGift extends AbstractSendRequest<SendGift> {
public SendGift(Long userId, String giftId) {
super(BaseResponse.class);
add("user_id", userId);
add("gift_id", giftId);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.pengrad.telegrambot.response;

import com.pengrad.telegrambot.model.Gift;
import com.pengrad.telegrambot.model.Gifts;

import java.util.Arrays;

public class GetAvailableGiftsResponse extends BaseResponse {
private Gifts result;

public Gifts gifts() {
return result;
}

@Override
public String toString() {
return "GetAvailableGiftsResponse{" +
"result=" + result +
'}';
}
}
Loading