Skip to content

Commit 5b75ca2

Browse files
author
Stanislav Parshin
authored
Merge pull request #89 from pengrad/v3
Bot API 3.0
2 parents 362f895 + 9d9a10c commit 5b75ca2

27 files changed

+975
-17
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.pengrad.telegrambot.model;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* Stas Parshin
7+
* 24 May 2017
8+
*/
9+
public class Invoice implements Serializable {
10+
private final static long serialVersionUID = 0L;
11+
12+
private String title, description, start_parameter, currency;
13+
private Integer total_amount;
14+
15+
public String title() {
16+
return title;
17+
}
18+
19+
public String description() {
20+
return description;
21+
}
22+
23+
public String startParameter() {
24+
return start_parameter;
25+
}
26+
27+
public String currency() {
28+
return currency;
29+
}
30+
31+
public Integer totalAmount() {
32+
return total_amount;
33+
}
34+
35+
@Override
36+
public boolean equals(Object o) {
37+
if (this == o) return true;
38+
if (o == null || getClass() != o.getClass()) return false;
39+
40+
Invoice invoice = (Invoice) o;
41+
42+
if (title != null ? !title.equals(invoice.title) : invoice.title != null) return false;
43+
if (description != null ? !description.equals(invoice.description) : invoice.description != null) return false;
44+
if (start_parameter != null ? !start_parameter.equals(invoice.start_parameter) : invoice.start_parameter != null)
45+
return false;
46+
if (currency != null ? !currency.equals(invoice.currency) : invoice.currency != null) return false;
47+
return total_amount != null ? total_amount.equals(invoice.total_amount) : invoice.total_amount == null;
48+
49+
}
50+
51+
@Override
52+
public int hashCode() {
53+
int result = title != null ? title.hashCode() : 0;
54+
result = 31 * result + (description != null ? description.hashCode() : 0);
55+
result = 31 * result + (start_parameter != null ? start_parameter.hashCode() : 0);
56+
result = 31 * result + (currency != null ? currency.hashCode() : 0);
57+
result = 31 * result + (total_amount != null ? total_amount.hashCode() : 0);
58+
return result;
59+
}
60+
61+
@Override
62+
public String toString() {
63+
return "Invoice{" +
64+
"title='" + title + '\'' +
65+
", description='" + description + '\'' +
66+
", start_parameter='" + start_parameter + '\'' +
67+
", currency='" + currency + '\'' +
68+
", total_amount=" + total_amount +
69+
'}';
70+
}
71+
}

library/src/main/java/com/pengrad/telegrambot/model/Message.java

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public class Message implements Serializable {
2929
private Sticker sticker;
3030
private Video video;
3131
private Voice voice;
32+
private VideoNote video_note;
33+
private User[] new_chat_members;
3234
private String caption;
3335
private Contact contact;
3436
private Location location;
@@ -44,6 +46,8 @@ public class Message implements Serializable {
4446
private Long migrate_to_chat_id;
4547
private Long migrate_from_chat_id;
4648
private Message pinned_message;
49+
private Invoice invoice;
50+
private SuccessfulPayment successful_payment;
4751

4852
public Integer messageId() {
4953
return message_id;
@@ -121,6 +125,14 @@ public Voice voice() {
121125
return voice;
122126
}
123127

128+
public VideoNote videoNote() {
129+
return video_note;
130+
}
131+
132+
public User[] newChatMembers() {
133+
return new_chat_members;
134+
}
135+
124136
public String caption() {
125137
return caption;
126138
}
@@ -137,6 +149,10 @@ public Venue venue() {
137149
return venue;
138150
}
139151

152+
/**
153+
* @deprecated Replaced with new_chat_members
154+
*/
155+
@Deprecated
140156
public User newChatMember() {
141157
return new_chat_member;
142158
}
@@ -181,6 +197,14 @@ public Message pinnedMessage() {
181197
return pinned_message;
182198
}
183199

200+
public Invoice invoice() {
201+
return invoice;
202+
}
203+
204+
public SuccessfulPayment successfulPayment() {
205+
return successful_payment;
206+
}
207+
184208
@Override
185209
public boolean equals(Object o) {
186210
if (this == o) return true;
@@ -192,14 +216,12 @@ public boolean equals(Object o) {
192216
if (from != null ? !from.equals(message.from) : message.from != null) return false;
193217
if (date != null ? !date.equals(message.date) : message.date != null) return false;
194218
if (chat != null ? !chat.equals(message.chat) : message.chat != null) return false;
195-
if (forward_from != null ? !forward_from.equals(message.forward_from) : message.forward_from != null)
196-
return false;
219+
if (forward_from != null ? !forward_from.equals(message.forward_from) : message.forward_from != null) return false;
197220
if (forward_from_chat != null ? !forward_from_chat.equals(message.forward_from_chat) : message.forward_from_chat != null)
198221
return false;
199222
if (forward_from_message_id != null ? !forward_from_message_id.equals(message.forward_from_message_id) : message.forward_from_message_id != null)
200223
return false;
201-
if (forward_date != null ? !forward_date.equals(message.forward_date) : message.forward_date != null)
202-
return false;
224+
if (forward_date != null ? !forward_date.equals(message.forward_date) : message.forward_date != null) return false;
203225
if (reply_to_message != null ? !reply_to_message.equals(message.reply_to_message) : message.reply_to_message != null)
204226
return false;
205227
if (edit_date != null ? !edit_date.equals(message.edit_date) : message.edit_date != null) return false;
@@ -214,6 +236,9 @@ public boolean equals(Object o) {
214236
if (sticker != null ? !sticker.equals(message.sticker) : message.sticker != null) return false;
215237
if (video != null ? !video.equals(message.video) : message.video != null) return false;
216238
if (voice != null ? !voice.equals(message.voice) : message.voice != null) return false;
239+
if (video_note != null ? !video_note.equals(message.video_note) : message.video_note != null) return false;
240+
// Probably incorrect - comparing Object[] arrays with Arrays.equals
241+
if (!Arrays.equals(new_chat_members, message.new_chat_members)) return false;
217242
if (caption != null ? !caption.equals(message.caption) : message.caption != null) return false;
218243
if (contact != null ? !contact.equals(message.contact) : message.contact != null) return false;
219244
if (location != null ? !location.equals(message.location) : message.location != null) return false;
@@ -238,8 +263,10 @@ public boolean equals(Object o) {
238263
return false;
239264
if (migrate_from_chat_id != null ? !migrate_from_chat_id.equals(message.migrate_from_chat_id) : message.migrate_from_chat_id != null)
240265
return false;
241-
return pinned_message != null ? pinned_message.equals(message.pinned_message) : message.pinned_message == null;
242-
266+
if (pinned_message != null ? !pinned_message.equals(message.pinned_message) : message.pinned_message != null)
267+
return false;
268+
if (invoice != null ? !invoice.equals(message.invoice) : message.invoice != null) return false;
269+
return successful_payment != null ? successful_payment.equals(message.successful_payment) : message.successful_payment == null;
243270
}
244271

245272
@Override
@@ -269,6 +296,8 @@ public String toString() {
269296
", sticker=" + sticker +
270297
", video=" + video +
271298
", voice=" + voice +
299+
", video_note=" + video_note +
300+
", new_chat_members=" + Arrays.toString(new_chat_members) +
272301
", caption='" + caption + '\'' +
273302
", contact=" + contact +
274303
", location=" + location +
@@ -284,6 +313,8 @@ public String toString() {
284313
", migrate_to_chat_id=" + migrate_to_chat_id +
285314
", migrate_from_chat_id=" + migrate_from_chat_id +
286315
", pinned_message=" + pinned_message +
316+
", invoice=" + invoice +
317+
", successful_payment=" + successful_payment +
287318
'}';
288319
}
289320
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.pengrad.telegrambot.model;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* Stas Parshin
7+
* 24 May 2017
8+
*/
9+
public class OrderInfo implements Serializable {
10+
private final static long serialVersionUID = 0L;
11+
12+
private String name, phone_number, email;
13+
private ShippingAddress shipping_address;
14+
15+
public String name() {
16+
return name;
17+
}
18+
19+
public String phoneNumber() {
20+
return phone_number;
21+
}
22+
23+
public String email() {
24+
return email;
25+
}
26+
27+
public ShippingAddress shippingAddress() {
28+
return shipping_address;
29+
}
30+
31+
@Override
32+
public boolean equals(Object o) {
33+
if (this == o) return true;
34+
if (o == null || getClass() != o.getClass()) return false;
35+
36+
OrderInfo orderInfo = (OrderInfo) o;
37+
38+
if (name != null ? !name.equals(orderInfo.name) : orderInfo.name != null) return false;
39+
if (phone_number != null ? !phone_number.equals(orderInfo.phone_number) : orderInfo.phone_number != null) return false;
40+
if (email != null ? !email.equals(orderInfo.email) : orderInfo.email != null) return false;
41+
return shipping_address != null ? shipping_address.equals(orderInfo.shipping_address) : orderInfo.shipping_address == null;
42+
43+
}
44+
45+
@Override
46+
public int hashCode() {
47+
int result = name != null ? name.hashCode() : 0;
48+
result = 31 * result + (phone_number != null ? phone_number.hashCode() : 0);
49+
result = 31 * result + (email != null ? email.hashCode() : 0);
50+
result = 31 * result + (shipping_address != null ? shipping_address.hashCode() : 0);
51+
return result;
52+
}
53+
54+
@Override
55+
public String toString() {
56+
return "OrderInfo{" +
57+
"name='" + name + '\'' +
58+
", phone_number='" + phone_number + '\'' +
59+
", email='" + email + '\'' +
60+
", shipping_address=" + shipping_address +
61+
'}';
62+
}
63+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.pengrad.telegrambot.model;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* Stas Parshin
7+
* 24 May 2017
8+
*/
9+
public class PreCheckoutQuery implements Serializable {
10+
private final static long serialVersionUID = 0L;
11+
12+
private String id;
13+
private User from;
14+
private String currency;
15+
private Integer total_amount;
16+
private String invoice_payload;
17+
private String shipping_option_id;
18+
private OrderInfo order_info;
19+
20+
public String id() {
21+
return id;
22+
}
23+
24+
public User from() {
25+
return from;
26+
}
27+
28+
public String currency() {
29+
return currency;
30+
}
31+
32+
public Integer totalAmount() {
33+
return total_amount;
34+
}
35+
36+
public String invoicePayload() {
37+
return invoice_payload;
38+
}
39+
40+
public String shippingOptionId() {
41+
return shipping_option_id;
42+
}
43+
44+
public OrderInfo orderInfo() {
45+
return order_info;
46+
}
47+
48+
@Override
49+
public boolean equals(Object o) {
50+
if (this == o) return true;
51+
if (o == null || getClass() != o.getClass()) return false;
52+
53+
PreCheckoutQuery that = (PreCheckoutQuery) o;
54+
55+
if (id != null ? !id.equals(that.id) : that.id != null) return false;
56+
if (from != null ? !from.equals(that.from) : that.from != null) return false;
57+
if (currency != null ? !currency.equals(that.currency) : that.currency != null) return false;
58+
if (total_amount != null ? !total_amount.equals(that.total_amount) : that.total_amount != null) return false;
59+
if (invoice_payload != null ? !invoice_payload.equals(that.invoice_payload) : that.invoice_payload != null)
60+
return false;
61+
if (shipping_option_id != null ? !shipping_option_id.equals(that.shipping_option_id) : that.shipping_option_id != null)
62+
return false;
63+
return order_info != null ? order_info.equals(that.order_info) : that.order_info == null;
64+
}
65+
66+
@Override
67+
public int hashCode() {
68+
return id != null ? id.hashCode() : 0;
69+
}
70+
71+
@Override
72+
public String toString() {
73+
return "PreCheckoutQuery{" +
74+
"id='" + id + '\'' +
75+
", from=" + from +
76+
", currency='" + currency + '\'' +
77+
", total_amount=" + total_amount +
78+
", invoice_payload='" + invoice_payload + '\'' +
79+
", shipping_option_id='" + shipping_option_id + '\'' +
80+
", order_info=" + order_info +
81+
'}';
82+
}
83+
}

0 commit comments

Comments
 (0)