wave_api/models/
common.rs1use rust_decimal::Decimal;
2use serde::Deserialize;
3
4use crate::enums::{CountryCode, CurrencyCode};
5
6#[derive(Debug, Clone, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct Money {
10 pub value: String,
12 pub currency: Currency,
14}
15
16impl Money {
17 pub fn decimal(&self) -> Result<Decimal, rust_decimal::Error> {
19 self.value.parse()
20 }
21}
22
23#[derive(Debug, Clone, Deserialize)]
25#[serde(rename_all = "camelCase")]
26pub struct Currency {
27 pub code: CurrencyCode,
28 pub symbol: String,
29 pub name: String,
30 pub plural: Option<String>,
31 pub exponent: Option<i32>,
32}
33
34#[derive(Debug, Clone, Deserialize)]
36#[serde(rename_all = "camelCase")]
37pub struct Country {
38 pub code: CountryCode,
39 pub name: String,
40 pub name_with_article: Option<String>,
41 pub currency: Option<Currency>,
42 pub provinces: Option<Vec<Province>>,
43}
44
45#[derive(Debug, Clone, Deserialize)]
47#[serde(rename_all = "camelCase")]
48pub struct Province {
49 pub code: String,
50 pub name: String,
51}
52
53#[derive(Debug, Clone, Deserialize)]
55#[serde(rename_all = "camelCase")]
56pub struct Address {
57 pub address_line1: Option<String>,
58 pub address_line2: Option<String>,
59 pub city: Option<String>,
60 pub province: Option<Province>,
61 pub country: Option<Country>,
62 pub postal_code: Option<String>,
63}
64
65#[derive(Debug, Clone, Deserialize)]
67#[serde(rename_all = "camelCase")]
68pub struct ShippingDetails {
69 pub name: Option<String>,
70 pub address: Option<Address>,
71 pub phone: Option<String>,
72 pub instructions: Option<String>,
73}