easydonate_api/v3/
shop.rs1use isahc::{send_async, AsyncReadResponseExt, Request};
2use serde::{Deserialize, Serialize};
3use crate::{result::{EasyResponse, EasyResult}, util::serde::bool_from_int};
4use super::types::user::User;
5
6#[derive(Deserialize, Serialize, Debug)]
7pub struct Shop {
8 pub id: i64,
9 pub rating: Option<f32>,
10 pub name: String,
11 pub domain: String,
12 pub last_domain: String,
13 pub delivery_type: String, pub description: Option<String>,
15 pub user_id: i64,
16 #[serde(deserialize_with = "bool_from_int")]
17 pub is_active: bool,
18 #[serde(deserialize_with = "bool_from_int")]
19 pub is_premium: bool,
20 #[serde(deserialize_with = "bool_from_int")]
21 pub hide_copyright: bool,
22 pub hide_copyright_till: Option<String>,
23 #[serde(deserialize_with = "bool_from_int")]
24 pub is_verified: bool,
25 pub vk_link: Option<String>,
26 pub youtube_link: Option<String>,
27 pub discord_link: Option<String>,
28 pub twitch_link: Option<String>,
29 pub instagram_link: Option<String>,
30 pub tiktok_link: Option<String>,
31 pub theme_id: i16,
32 pub background: String,
33 pub logo: String,
34 pub favicon: String,
35 pub css: Option<String>,
36
37 #[serde(deserialize_with = "bool_from_int")]
38 pub enable_background_overlay: bool,
39 #[serde(deserialize_with = "bool_from_int")]
40 pub hide_side_image: bool,
41 #[serde(deserialize_with = "bool_from_int")]
42 pub hide_general_online: bool,
43 pub products_image_padding: i16,
44 #[serde(deserialize_with = "bool_from_int")]
45 pub hide_servers: bool,
46 #[serde(deserialize_with = "bool_from_int")]
47 pub test_mode: bool,
48 pub test_mode_from: Option<String>,
49 pub created_at: String,
50 pub updated_at: String,
51 pub side: String,
52 pub key: String,
53 pub color: String,
54 #[serde(deserialize_with = "bool_from_int")]
55 pub require_email: bool,
56 pub pay_comission: i32,
57 pub particles: String,
58 pub is_api_moderated: Option<bool>,
59 #[serde(deserialize_with = "bool_from_int")]
60 pub is_api_pending_moderation: bool,
61 pub api_moderated_at: Option<String>,
62 pub api_domain: Option<String>,
63 pub sort_index: Option<String>,
64 #[serde(deserialize_with = "bool_from_int")]
65 pub https_redirect: bool,
66 #[serde(deserialize_with = "bool_from_int")]
67 pub allow_nickname_spaces: bool,
68 pub game_id: i16,
69 #[serde(deserialize_with = "bool_from_int")]
70 pub hide_payment_instruction: bool,
71 pub payment_instruction: Option<String>,
72 #[serde(deserialize_with = "bool_from_int")]
73 pub use_cart: bool,
74 pub user: User
75}
76
77pub async fn get_shop(shop_key: String) -> EasyResult<Shop> {
80 let request = Request::get("https://easydonate.ru/api/v3/shop")
81 .header("Shop-Key", shop_key)
82 .body(())?;
83
84 let mut response = send_async(request)
85 .await?;
86
87 let body = response.text()
88 .await?;
89
90 let des = serde_json::from_str::<EasyResponse<Shop>>(&body)?;
91
92 Ok(des.result()?)
93}