mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Put all the existing types into core/types
This commit is contained in:
parent
c4fcc13dcd
commit
72be7ee750
22 changed files with 220 additions and 175 deletions
|
@ -1,5 +1,3 @@
|
||||||
mod network;
|
mod network;
|
||||||
mod requests;
|
pub mod requests;
|
||||||
|
pub mod types;
|
||||||
mod other;
|
|
||||||
mod payments;
|
|
||||||
|
|
|
@ -1,114 +0,0 @@
|
||||||
use crate::core::other::User;
|
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct SendInvoice {
|
|
||||||
chat_id: i64,
|
|
||||||
title: String,
|
|
||||||
description: String,
|
|
||||||
payload: String,
|
|
||||||
provider_token: String,
|
|
||||||
start_parameter: String,
|
|
||||||
currency: String,
|
|
||||||
prices: Vec<LabeledPrice>,
|
|
||||||
provider_data: Option<String>,
|
|
||||||
photo_url: Option<String>,
|
|
||||||
photo_size: Option<i64>,
|
|
||||||
photo_width: Option<i64>,
|
|
||||||
photo_height: Option<i64>,
|
|
||||||
need_name: Option<bool>,
|
|
||||||
need_phone_number: Option<bool>,
|
|
||||||
need_email: Option<bool>,
|
|
||||||
need_shipping_address: Option<bool>,
|
|
||||||
send_phone_number_to_provider: Option<bool>,
|
|
||||||
send_email_to_provider: Option<bool>,
|
|
||||||
is_flexible: Option<bool>,
|
|
||||||
disable_notification: Option<bool>,
|
|
||||||
reply_to_message_id: Option<i64>,
|
|
||||||
reply_markup: Option<InlineKeyboardMarkup>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct AnswerShippingQuery {
|
|
||||||
shipping_query_id: String,
|
|
||||||
ok: bool,
|
|
||||||
shipping_options: Option<Vec<ShippingOption>>,
|
|
||||||
error_message: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct AnswerPreCheckoutQuery {
|
|
||||||
pre_checkout_query_id: String,
|
|
||||||
ok: bool,
|
|
||||||
error_message: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct LabeledPrice {
|
|
||||||
label: String,
|
|
||||||
amount: i64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct Invoice {
|
|
||||||
title: String,
|
|
||||||
description: String,
|
|
||||||
start_parameter: String,
|
|
||||||
currency: String,
|
|
||||||
total_amount: i64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct ShippingAddress {
|
|
||||||
country_code: String,
|
|
||||||
state: String,
|
|
||||||
city: String,
|
|
||||||
street_line1: String,
|
|
||||||
street_line2: String,
|
|
||||||
post_code: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct OrderInfo {
|
|
||||||
name: String,
|
|
||||||
phone_number: String,
|
|
||||||
email: String,
|
|
||||||
shipping_address: ShippingAddress,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct ShippingOption {
|
|
||||||
id: i64,
|
|
||||||
title: String,
|
|
||||||
prices: Vec<LabeledPrice>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct SuccessfulPayment {
|
|
||||||
currency: String,
|
|
||||||
total_amount: i64,
|
|
||||||
invoice_payload: String,
|
|
||||||
shipping_option_id: Option<String>,
|
|
||||||
order_info: Option<OrderInfo>,
|
|
||||||
telegram_payment_charge_id: String,
|
|
||||||
provider_payment_charge_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct ShippingQuery {
|
|
||||||
id: String,
|
|
||||||
from: User,
|
|
||||||
invoice_payload: String,
|
|
||||||
shipping_address: ShippingAddress,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct PreCheckoutQuery {
|
|
||||||
id: String,
|
|
||||||
from: User,
|
|
||||||
currency: String,
|
|
||||||
total_amount: i64,
|
|
||||||
invoice_payload: String,
|
|
||||||
shipping_option_id: Option<String>,
|
|
||||||
order_info: Option<OrderInfo>,
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
use super::Request;
|
use super::Request;
|
||||||
use crate::core::other::User;
|
|
||||||
|
|
||||||
use reqwest::r#async::multipart::Form;
|
use reqwest::r#async::multipart::Form;
|
||||||
|
use crate::core::types::User;
|
||||||
|
|
||||||
#[derive(Debug, Constructor, PartialEq, Eq)]
|
#[derive(Debug, Constructor, PartialEq, Eq)]
|
||||||
pub struct GetMe {
|
pub struct GetMe {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use super::{ChatId, Request};
|
use super::{ChatId, Request};
|
||||||
use crate::core::other::Message;
|
use crate::core::types::Message;
|
||||||
|
|
||||||
use reqwest::r#async::multipart::Form;
|
use reqwest::r#async::multipart::Form;
|
||||||
|
|
||||||
|
|
8
src/core/types/answer_pre_checkout_query.rs
Normal file
8
src/core/types/answer_pre_checkout_query.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct AnswerPreCheckoutQuery {
|
||||||
|
pre_checkout_query_id: String,
|
||||||
|
ok: bool,
|
||||||
|
error_message: Option<String>,
|
||||||
|
}
|
10
src/core/types/answer_shipping_query.rs
Normal file
10
src/core/types/answer_shipping_query.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
use crate::core::types::ShippingOption;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct AnswerShippingQuery {
|
||||||
|
shipping_query_id: String,
|
||||||
|
ok: bool,
|
||||||
|
shipping_options: Option<Vec<ShippingOption>>,
|
||||||
|
error_message: Option<String>,
|
||||||
|
}
|
19
src/core/types/chat.rs
Normal file
19
src/core/types/chat.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
use crate::core::types::{ChatPhoto, ChatPermissions, Message};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct Chat {
|
||||||
|
id: i64,
|
||||||
|
chat_type: String,
|
||||||
|
title: Option<String>,
|
||||||
|
username: Option<String>,
|
||||||
|
first_name: Option<String>,
|
||||||
|
last_name: Option<String>,
|
||||||
|
photo: Option<ChatPhoto>,
|
||||||
|
description: Option<String>,
|
||||||
|
invite_link: Option<String>,
|
||||||
|
pinned_message: Option<Box<Message>>,
|
||||||
|
permissions: Option<ChatPermissions>,
|
||||||
|
sticker_set_name: Option<String>,
|
||||||
|
can_set_sticker_set: Option<bool>,
|
||||||
|
}
|
13
src/core/types/chat_permissions.rs
Normal file
13
src/core/types/chat_permissions.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ChatPermissions {
|
||||||
|
can_send_messages: Option<bool>,
|
||||||
|
can_send_media_messages: Option<bool>,
|
||||||
|
can_send_polls: Option<bool>,
|
||||||
|
can_send_other_messages: Option<bool>,
|
||||||
|
can_add_web_page_previews: Option<bool>,
|
||||||
|
can_change_info: Option<bool>,
|
||||||
|
can_invite_users: Option<bool>,
|
||||||
|
can_pin_messages: Option<bool>,
|
||||||
|
}
|
7
src/core/types/chat_photo.rs
Normal file
7
src/core/types/chat_photo.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ChatPhoto {
|
||||||
|
small_file_id: String,
|
||||||
|
big_file_id: String,
|
||||||
|
}
|
10
src/core/types/document.rs
Normal file
10
src/core/types/document.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct Document {
|
||||||
|
file_id: String,
|
||||||
|
thumb: Option<PhotoSize>,
|
||||||
|
file_name: Option<String>,
|
||||||
|
mime_type: Option<String>,
|
||||||
|
file_size: Option<i64>,
|
||||||
|
}
|
10
src/core/types/invoice.rs
Normal file
10
src/core/types/invoice.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct Invoice {
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
start_parameter: String,
|
||||||
|
currency: String,
|
||||||
|
total_amount: i64,
|
||||||
|
}
|
7
src/core/types/label_price.rs
Normal file
7
src/core/types/label_price.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct LabeledPrice {
|
||||||
|
label: String,
|
||||||
|
amount: i64,
|
||||||
|
}
|
|
@ -1,32 +1,5 @@
|
||||||
use crate::core::payments::{Invoice, SuccessfulPayment};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use crate::core::types::{User, Chat, Document, Invoice, SuccessfulPayment};
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct User {
|
|
||||||
id: i64,
|
|
||||||
is_bot: bool,
|
|
||||||
first_name: String,
|
|
||||||
last_name: Option<String>,
|
|
||||||
username: Option<String>,
|
|
||||||
language_code: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct Chat {
|
|
||||||
id: i64,
|
|
||||||
chat_type: String,
|
|
||||||
title: Option<String>,
|
|
||||||
username: Option<String>,
|
|
||||||
first_name: Option<String>,
|
|
||||||
last_name: Option<String>,
|
|
||||||
photo: Option<ChatPhoto>,
|
|
||||||
description: Option<String>,
|
|
||||||
invite_link: Option<String>,
|
|
||||||
pinned_message: Option<Box<Message>>,
|
|
||||||
permissions: Option<ChatPermissions>,
|
|
||||||
sticker_set_name: Option<String>,
|
|
||||||
can_set_sticker_set: Option<bool>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
|
@ -78,30 +51,3 @@ pub struct Message {
|
||||||
passport_data: Option<PassportData>,
|
passport_data: Option<PassportData>,
|
||||||
reply_markup: Option<InlineKeyboardMarkup>,
|
reply_markup: Option<InlineKeyboardMarkup>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct ChatPhoto {
|
|
||||||
small_file_id: String,
|
|
||||||
big_file_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct ChatPermissions {
|
|
||||||
can_send_messages: Option<bool>,
|
|
||||||
can_send_media_messages: Option<bool>,
|
|
||||||
can_send_polls: Option<bool>,
|
|
||||||
can_send_other_messages: Option<bool>,
|
|
||||||
can_add_web_page_previews: Option<bool>,
|
|
||||||
can_change_info: Option<bool>,
|
|
||||||
can_invite_users: Option<bool>,
|
|
||||||
can_pin_messages: Option<bool>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct Document {
|
|
||||||
file_id: String,
|
|
||||||
thumb: Option<PhotoSize>,
|
|
||||||
file_name: Option<String>,
|
|
||||||
mime_type: Option<String>,
|
|
||||||
file_size: Option<i64>,
|
|
||||||
}
|
|
25
src/core/types/mod.rs
Normal file
25
src/core/types/mod.rs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
pub use self::{
|
||||||
|
answer_pre_checkout_query::AnswerPreCheckoutQuery, answer_shipping_query::AnswerShippingQuery,
|
||||||
|
chat::Chat, chat_permissions::ChatPermissions, chat_photo::ChatPhoto, document::Document,
|
||||||
|
invoice::Invoice, label_price::LabeledPrice, message::Message, order_info::OrderInfo,
|
||||||
|
pre_checkout_query::PreCheckoutQuery, send_invoice::SendInvoice, shipping_address::ShippingAddress,
|
||||||
|
shipping_option::ShippingOption, shipping_query::ShippingQuery, successful_payment::SuccessfulPayment, user::User,
|
||||||
|
};
|
||||||
|
|
||||||
|
mod answer_pre_checkout_query;
|
||||||
|
mod answer_shipping_query;
|
||||||
|
mod chat;
|
||||||
|
mod chat_permissions;
|
||||||
|
mod chat_photo;
|
||||||
|
mod document;
|
||||||
|
mod invoice;
|
||||||
|
mod label_price;
|
||||||
|
mod message;
|
||||||
|
mod order_info;
|
||||||
|
mod pre_checkout_query;
|
||||||
|
mod send_invoice;
|
||||||
|
mod shipping_address;
|
||||||
|
mod shipping_option;
|
||||||
|
mod shipping_query;
|
||||||
|
mod successful_payment;
|
||||||
|
mod user;
|
10
src/core/types/order_info.rs
Normal file
10
src/core/types/order_info.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
use crate::core::types::ShippingAddress;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct OrderInfo {
|
||||||
|
name: String,
|
||||||
|
phone_number: String,
|
||||||
|
email: String,
|
||||||
|
shipping_address: ShippingAddress,
|
||||||
|
}
|
13
src/core/types/pre_checkout_query.rs
Normal file
13
src/core/types/pre_checkout_query.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
use crate::core::types::{User, OrderInfo};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct PreCheckoutQuery {
|
||||||
|
id: String,
|
||||||
|
from: User,
|
||||||
|
currency: String,
|
||||||
|
total_amount: i64,
|
||||||
|
invoice_payload: String,
|
||||||
|
shipping_option_id: Option<String>,
|
||||||
|
order_info: Option<OrderInfo>,
|
||||||
|
}
|
29
src/core/types/send_invoice.rs
Normal file
29
src/core/types/send_invoice.rs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
use crate::core::types::LabeledPrice;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct SendInvoice {
|
||||||
|
chat_id: i64,
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
payload: String,
|
||||||
|
provider_token: String,
|
||||||
|
start_parameter: String,
|
||||||
|
currency: String,
|
||||||
|
prices: Vec<LabeledPrice>,
|
||||||
|
provider_data: Option<String>,
|
||||||
|
photo_url: Option<String>,
|
||||||
|
photo_size: Option<i64>,
|
||||||
|
photo_width: Option<i64>,
|
||||||
|
photo_height: Option<i64>,
|
||||||
|
need_name: Option<bool>,
|
||||||
|
need_phone_number: Option<bool>,
|
||||||
|
need_email: Option<bool>,
|
||||||
|
need_shipping_address: Option<bool>,
|
||||||
|
send_phone_number_to_provider: Option<bool>,
|
||||||
|
send_email_to_provider: Option<bool>,
|
||||||
|
is_flexible: Option<bool>,
|
||||||
|
disable_notification: Option<bool>,
|
||||||
|
reply_to_message_id: Option<i64>,
|
||||||
|
reply_markup: Option<InlineKeyboardMarkup>,
|
||||||
|
}
|
11
src/core/types/shipping_address.rs
Normal file
11
src/core/types/shipping_address.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ShippingAddress {
|
||||||
|
country_code: String,
|
||||||
|
state: String,
|
||||||
|
city: String,
|
||||||
|
street_line1: String,
|
||||||
|
street_line2: String,
|
||||||
|
post_code: String,
|
||||||
|
}
|
9
src/core/types/shipping_option.rs
Normal file
9
src/core/types/shipping_option.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
use crate::core::types::LabeledPrice;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ShippingOption {
|
||||||
|
id: i64,
|
||||||
|
title: String,
|
||||||
|
prices: Vec<LabeledPrice>,
|
||||||
|
}
|
10
src/core/types/shipping_query.rs
Normal file
10
src/core/types/shipping_query.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
use crate::core::types::{User, ShippingAddress};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct ShippingQuery {
|
||||||
|
id: String,
|
||||||
|
from: User,
|
||||||
|
invoice_payload: String,
|
||||||
|
shipping_address: ShippingAddress,
|
||||||
|
}
|
13
src/core/types/successful_payment.rs
Normal file
13
src/core/types/successful_payment.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
use crate::core::types::OrderInfo;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct SuccessfulPayment {
|
||||||
|
currency: String,
|
||||||
|
total_amount: i64,
|
||||||
|
invoice_payload: String,
|
||||||
|
shipping_option_id: Option<String>,
|
||||||
|
order_info: Option<OrderInfo>,
|
||||||
|
telegram_payment_charge_id: String,
|
||||||
|
provider_payment_charge_id: String,
|
||||||
|
}
|
11
src/core/types/user.rs
Normal file
11
src/core/types/user.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct User {
|
||||||
|
id: i64,
|
||||||
|
is_bot: bool,
|
||||||
|
first_name: String,
|
||||||
|
last_name: Option<String>,
|
||||||
|
username: Option<String>,
|
||||||
|
language_code: Option<String>,
|
||||||
|
}
|
Loading…
Reference in a new issue