Skip to content

Commit bffe4ba

Browse files
committed
Added new kinds of updates, shipping_query and pre_checkout_query, and new types of message content, invoice and successful_payment.
Added new methods for payments: sendInvoice, answerShippingQuery, and answerPreCheckoutQuery. Added a new type of button, the pay button to InlineKeyboardButton.
1 parent 884670e commit bffe4ba

File tree

16 files changed

+731
-8
lines changed

16 files changed

+731
-8
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: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public class Message implements Serializable {
4646
private Long migrate_to_chat_id;
4747
private Long migrate_from_chat_id;
4848
private Message pinned_message;
49+
private Invoice invoice;
50+
private SuccessfulPayment successful_payment;
4951

5052
public Integer messageId() {
5153
return message_id;
@@ -195,6 +197,14 @@ public Message pinnedMessage() {
195197
return pinned_message;
196198
}
197199

200+
public Invoice invoice() {
201+
return invoice;
202+
}
203+
204+
public SuccessfulPayment successfulPayment() {
205+
return successful_payment;
206+
}
207+
198208
@Override
199209
public boolean equals(Object o) {
200210
if (this == o) return true;
@@ -253,7 +263,10 @@ public boolean equals(Object o) {
253263
return false;
254264
if (migrate_from_chat_id != null ? !migrate_from_chat_id.equals(message.migrate_from_chat_id) : message.migrate_from_chat_id != null)
255265
return false;
256-
return pinned_message != null ? pinned_message.equals(message.pinned_message) : message.pinned_message == null;
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;
257270
}
258271

259272
@Override
@@ -300,6 +313,8 @@ public String toString() {
300313
", migrate_to_chat_id=" + migrate_to_chat_id +
301314
", migrate_from_chat_id=" + migrate_from_chat_id +
302315
", pinned_message=" + pinned_message +
316+
", invoice=" + invoice +
317+
", successful_payment=" + successful_payment +
303318
'}';
304319
}
305320
}
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+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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 ShippingAddress implements Serializable {
10+
private final static long serialVersionUID = 0L;
11+
12+
private String country_code, state, city, street_line1, street_line2, post_code;
13+
14+
public String countryCode() {
15+
return country_code;
16+
}
17+
18+
public String state() {
19+
return state;
20+
}
21+
22+
public String city() {
23+
return city;
24+
}
25+
26+
public String streetLine1() {
27+
return street_line1;
28+
}
29+
30+
public String streetLine2() {
31+
return street_line2;
32+
}
33+
34+
public String postCode() {
35+
return post_code;
36+
}
37+
38+
@Override
39+
public boolean equals(Object o) {
40+
if (this == o) return true;
41+
if (o == null || getClass() != o.getClass()) return false;
42+
43+
ShippingAddress that = (ShippingAddress) o;
44+
45+
if (country_code != null ? !country_code.equals(that.country_code) : that.country_code != null) return false;
46+
if (state != null ? !state.equals(that.state) : that.state != null) return false;
47+
if (city != null ? !city.equals(that.city) : that.city != null) return false;
48+
if (street_line1 != null ? !street_line1.equals(that.street_line1) : that.street_line1 != null) return false;
49+
if (street_line2 != null ? !street_line2.equals(that.street_line2) : that.street_line2 != null) return false;
50+
return post_code != null ? post_code.equals(that.post_code) : that.post_code == null;
51+
52+
}
53+
54+
@Override
55+
public int hashCode() {
56+
int result = country_code != null ? country_code.hashCode() : 0;
57+
result = 31 * result + (state != null ? state.hashCode() : 0);
58+
result = 31 * result + (city != null ? city.hashCode() : 0);
59+
result = 31 * result + (street_line1 != null ? street_line1.hashCode() : 0);
60+
result = 31 * result + (street_line2 != null ? street_line2.hashCode() : 0);
61+
result = 31 * result + (post_code != null ? post_code.hashCode() : 0);
62+
return result;
63+
}
64+
65+
@Override
66+
public String toString() {
67+
return "ShippingAddress{" +
68+
"country_code='" + country_code + '\'' +
69+
", state='" + state + '\'' +
70+
", city='" + city + '\'' +
71+
", street_line1='" + street_line1 + '\'' +
72+
", street_line2='" + street_line2 + '\'' +
73+
", post_code='" + post_code + '\'' +
74+
'}';
75+
}
76+
}

0 commit comments

Comments
 (0)