Skip to content
Merged
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
71 changes: 71 additions & 0 deletions library/src/main/java/com/pengrad/telegrambot/model/Invoice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.pengrad.telegrambot.model;

import java.io.Serializable;

/**
* Stas Parshin
* 24 May 2017
*/
public class Invoice implements Serializable {
private final static long serialVersionUID = 0L;

private String title, description, start_parameter, currency;
private Integer total_amount;

public String title() {
return title;
}

public String description() {
return description;
}

public String startParameter() {
return start_parameter;
}

public String currency() {
return currency;
}

public Integer totalAmount() {
return total_amount;
}

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

Invoice invoice = (Invoice) o;

if (title != null ? !title.equals(invoice.title) : invoice.title != null) return false;
if (description != null ? !description.equals(invoice.description) : invoice.description != null) return false;
if (start_parameter != null ? !start_parameter.equals(invoice.start_parameter) : invoice.start_parameter != null)
return false;
if (currency != null ? !currency.equals(invoice.currency) : invoice.currency != null) return false;
return total_amount != null ? total_amount.equals(invoice.total_amount) : invoice.total_amount == null;

}

@Override
public int hashCode() {
int result = title != null ? title.hashCode() : 0;
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (start_parameter != null ? start_parameter.hashCode() : 0);
result = 31 * result + (currency != null ? currency.hashCode() : 0);
result = 31 * result + (total_amount != null ? total_amount.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "Invoice{" +
"title='" + title + '\'' +
", description='" + description + '\'' +
", start_parameter='" + start_parameter + '\'' +
", currency='" + currency + '\'' +
", total_amount=" + total_amount +
'}';
}
}
43 changes: 37 additions & 6 deletions library/src/main/java/com/pengrad/telegrambot/model/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class Message implements Serializable {
private Sticker sticker;
private Video video;
private Voice voice;
private VideoNote video_note;
private User[] new_chat_members;
private String caption;
private Contact contact;
private Location location;
Expand All @@ -44,6 +46,8 @@ public class Message implements Serializable {
private Long migrate_to_chat_id;
private Long migrate_from_chat_id;
private Message pinned_message;
private Invoice invoice;
private SuccessfulPayment successful_payment;

public Integer messageId() {
return message_id;
Expand Down Expand Up @@ -121,6 +125,14 @@ public Voice voice() {
return voice;
}

public VideoNote videoNote() {
return video_note;
}

public User[] newChatMembers() {
return new_chat_members;
}

public String caption() {
return caption;
}
Expand All @@ -137,6 +149,10 @@ public Venue venue() {
return venue;
}

/**
* @deprecated Replaced with new_chat_members
*/
@Deprecated
public User newChatMember() {
return new_chat_member;
}
Expand Down Expand Up @@ -181,6 +197,14 @@ public Message pinnedMessage() {
return pinned_message;
}

public Invoice invoice() {
return invoice;
}

public SuccessfulPayment successfulPayment() {
return successful_payment;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -192,14 +216,12 @@ public boolean equals(Object o) {
if (from != null ? !from.equals(message.from) : message.from != null) return false;
if (date != null ? !date.equals(message.date) : message.date != null) return false;
if (chat != null ? !chat.equals(message.chat) : message.chat != null) return false;
if (forward_from != null ? !forward_from.equals(message.forward_from) : message.forward_from != null)
return false;
if (forward_from != null ? !forward_from.equals(message.forward_from) : message.forward_from != null) return false;
if (forward_from_chat != null ? !forward_from_chat.equals(message.forward_from_chat) : message.forward_from_chat != null)
return false;
if (forward_from_message_id != null ? !forward_from_message_id.equals(message.forward_from_message_id) : message.forward_from_message_id != null)
return false;
if (forward_date != null ? !forward_date.equals(message.forward_date) : message.forward_date != null)
return false;
if (forward_date != null ? !forward_date.equals(message.forward_date) : message.forward_date != null) return false;
if (reply_to_message != null ? !reply_to_message.equals(message.reply_to_message) : message.reply_to_message != null)
return false;
if (edit_date != null ? !edit_date.equals(message.edit_date) : message.edit_date != null) return false;
Expand All @@ -214,6 +236,9 @@ public boolean equals(Object o) {
if (sticker != null ? !sticker.equals(message.sticker) : message.sticker != null) return false;
if (video != null ? !video.equals(message.video) : message.video != null) return false;
if (voice != null ? !voice.equals(message.voice) : message.voice != null) return false;
if (video_note != null ? !video_note.equals(message.video_note) : message.video_note != null) return false;
// Probably incorrect - comparing Object[] arrays with Arrays.equals
if (!Arrays.equals(new_chat_members, message.new_chat_members)) return false;
if (caption != null ? !caption.equals(message.caption) : message.caption != null) return false;
if (contact != null ? !contact.equals(message.contact) : message.contact != null) return false;
if (location != null ? !location.equals(message.location) : message.location != null) return false;
Expand All @@ -238,8 +263,10 @@ public boolean equals(Object o) {
return false;
if (migrate_from_chat_id != null ? !migrate_from_chat_id.equals(message.migrate_from_chat_id) : message.migrate_from_chat_id != null)
return false;
return pinned_message != null ? pinned_message.equals(message.pinned_message) : message.pinned_message == null;

if (pinned_message != null ? !pinned_message.equals(message.pinned_message) : message.pinned_message != null)
return false;
if (invoice != null ? !invoice.equals(message.invoice) : message.invoice != null) return false;
return successful_payment != null ? successful_payment.equals(message.successful_payment) : message.successful_payment == null;
}

@Override
Expand Down Expand Up @@ -269,6 +296,8 @@ public String toString() {
", sticker=" + sticker +
", video=" + video +
", voice=" + voice +
", video_note=" + video_note +
", new_chat_members=" + Arrays.toString(new_chat_members) +
", caption='" + caption + '\'' +
", contact=" + contact +
", location=" + location +
Expand All @@ -284,6 +313,8 @@ public String toString() {
", migrate_to_chat_id=" + migrate_to_chat_id +
", migrate_from_chat_id=" + migrate_from_chat_id +
", pinned_message=" + pinned_message +
", invoice=" + invoice +
", successful_payment=" + successful_payment +
'}';
}
}
63 changes: 63 additions & 0 deletions library/src/main/java/com/pengrad/telegrambot/model/OrderInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.pengrad.telegrambot.model;

import java.io.Serializable;

/**
* Stas Parshin
* 24 May 2017
*/
public class OrderInfo implements Serializable {
private final static long serialVersionUID = 0L;

private String name, phone_number, email;
private ShippingAddress shipping_address;

public String name() {
return name;
}

public String phoneNumber() {
return phone_number;
}

public String email() {
return email;
}

public ShippingAddress shippingAddress() {
return shipping_address;
}

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

OrderInfo orderInfo = (OrderInfo) o;

if (name != null ? !name.equals(orderInfo.name) : orderInfo.name != null) return false;
if (phone_number != null ? !phone_number.equals(orderInfo.phone_number) : orderInfo.phone_number != null) return false;
if (email != null ? !email.equals(orderInfo.email) : orderInfo.email != null) return false;
return shipping_address != null ? shipping_address.equals(orderInfo.shipping_address) : orderInfo.shipping_address == null;

}

@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (phone_number != null ? phone_number.hashCode() : 0);
result = 31 * result + (email != null ? email.hashCode() : 0);
result = 31 * result + (shipping_address != null ? shipping_address.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "OrderInfo{" +
"name='" + name + '\'' +
", phone_number='" + phone_number + '\'' +
", email='" + email + '\'' +
", shipping_address=" + shipping_address +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.pengrad.telegrambot.model;

import java.io.Serializable;

/**
* Stas Parshin
* 24 May 2017
*/
public class PreCheckoutQuery implements Serializable {
private final static long serialVersionUID = 0L;

private String id;
private User from;
private String currency;
private Integer total_amount;
private String invoice_payload;
private String shipping_option_id;
private OrderInfo order_info;

public String id() {
return id;
}

public User from() {
return from;
}

public String currency() {
return currency;
}

public Integer totalAmount() {
return total_amount;
}

public String invoicePayload() {
return invoice_payload;
}

public String shippingOptionId() {
return shipping_option_id;
}

public OrderInfo orderInfo() {
return order_info;
}

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

PreCheckoutQuery that = (PreCheckoutQuery) o;

if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (from != null ? !from.equals(that.from) : that.from != null) return false;
if (currency != null ? !currency.equals(that.currency) : that.currency != null) return false;
if (total_amount != null ? !total_amount.equals(that.total_amount) : that.total_amount != null) return false;
if (invoice_payload != null ? !invoice_payload.equals(that.invoice_payload) : that.invoice_payload != null)
return false;
if (shipping_option_id != null ? !shipping_option_id.equals(that.shipping_option_id) : that.shipping_option_id != null)
return false;
return order_info != null ? order_info.equals(that.order_info) : that.order_info == null;
}

@Override
public int hashCode() {
return id != null ? id.hashCode() : 0;
}

@Override
public String toString() {
return "PreCheckoutQuery{" +
"id='" + id + '\'' +
", from=" + from +
", currency='" + currency + '\'' +
", total_amount=" + total_amount +
", invoice_payload='" + invoice_payload + '\'' +
", shipping_option_id='" + shipping_option_id + '\'' +
", order_info=" + order_info +
'}';
}
}
Loading