rust_woocommerce/models/
shipping_zone_methods.rs

1use crate::controllers::Entity;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct ShippingZoneMethod {
6    pub id: i64,
7    /// Shipping method instance ID.
8    pub instance_id: i32,
9    /// Shipping method customer facing title.
10    pub title: String,
11    /// Shipping method sort order.
12    pub order: i32,
13    /// Shipping method enabled status.
14    pub enabled: bool,
15    /// Shipping method ID.
16    pub method_id: String,
17    /// Shipping method title.
18    pub method_title: String,
19    /// Shipping method description.
20    pub method_description: String,
21    /// Shipping method settings.
22    pub settings: ShippingSettings,
23}
24impl Entity for ShippingZoneMethod {
25    fn endpoint() -> String {
26        String::new()
27    }
28
29    fn child_endpoint(parent_id: i32) -> String {
30        format!("shipping/zones/{parent_id}/methods/")
31    }
32}
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct ShippingSettings {
35    pub title: ShippingMethodSettings,
36    pub requires: Option<ShippingMethodSettings>,
37}
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct ShippingMethodSettings {
40    /// A unique identifier for the setting.
41    pub id: String,
42    /// A human readable label for the setting used in interfaces.
43    pub label: String,
44    /// A human readable description for the setting used in interfaces.
45    pub description: String,
46    /// Type of setting. Options: text, email, number, color, password, textarea, select, multiselect, radio, image_width and checkbox.
47    #[serde(rename = "type")]
48    pub settings_type: SettingsType,
49    /// Setting value.
50    pub value: String,
51    /// Default value for the setting.
52    #[serde(rename = "default")]
53    pub default_value: String,
54    /// Additional help text shown to the user about the setting.
55    pub tip: String,
56    /// Placeholder text to be displayed in text inputs.
57    pub placeholder: String,
58    pub options: Option<serde_json::Value>,
59}
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(rename_all = "snake_case")]
62pub enum SettingsType {
63    Text,
64    Email,
65    Number,
66    Color,
67    Password,
68    Textarea,
69    Select,
70    Multiselect,
71    Radio,
72    ImageWidth,
73    Checkbox,
74}