rust_woocommerce/models/
payment_gateways.rs1use crate::controllers::Entity;
2use serde::{Deserialize, Serialize};
3
4use crate::controllers::payment_gateways::PaymentGatewayUpdate;
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct PaymentGateway {
7 pub id: String,
9 pub title: String,
11 pub description: String,
13 pub order: String,
15 pub enabled: bool,
17 pub method_title: String,
19 pub method_description: String,
21 pub method_supports: Vec<String>,
23 pub settings: PaymentGatewaySettings,
25}
26impl Entity for PaymentGateway {
27 fn endpoint() -> String {
28 String::from("payment_gateways/")
29 }
30
31 fn child_endpoint(parent_id: i32) -> String {
32 let _ = parent_id;
33 String::new()
34 }
35}
36impl PaymentGateway {
37 pub fn turn_on() -> PaymentGatewayUpdate {
38 PaymentGatewayUpdate { enabled: true }
39 }
40 pub fn turn_off() -> PaymentGatewayUpdate {
41 PaymentGatewayUpdate { enabled: false }
42 }
43}
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct PaymentGatewaySettings {
46 pub title: TitleInstructions,
47 pub instructions: TitleInstructions,
48}
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct TitleInstructions {
51 pub id: String,
53 pub label: String,
55 pub description: String,
57 #[serde(rename = "type")]
59 pub setting_type: SettingType,
60 pub value: String,
62 pub default: String,
64 pub tip: String,
66 pub placeholder: String,
68}
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(rename_all = "snake_case")]
71pub enum SettingType {
72 Text,
73 Email,
74 Number,
75 Color,
76 Password,
77 Textarea,
78 Select,
79 Multiselect,
80 Radio,
81 ImageWidth,
82 Checkbox,
83 SafeText,
84}