Skip to main content

wave_api/inputs/
address.rs

1use serde::Serialize;
2
3use crate::enums::CountryCode;
4
5/// Input for an address on mutations.
6#[derive(Debug, Clone, Default, Serialize)]
7#[serde(rename_all = "camelCase")]
8pub struct AddressInput {
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub address_line1: Option<String>,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub address_line2: Option<String>,
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub city: Option<String>,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub province_code: Option<String>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub country_code: Option<CountryCode>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub postal_code: Option<String>,
21}
22
23impl AddressInput {
24    pub fn new() -> Self {
25        Self::default()
26    }
27
28    pub fn address_line1(mut self, v: impl Into<String>) -> Self {
29        self.address_line1 = Some(v.into());
30        self
31    }
32
33    pub fn address_line2(mut self, v: impl Into<String>) -> Self {
34        self.address_line2 = Some(v.into());
35        self
36    }
37
38    pub fn city(mut self, v: impl Into<String>) -> Self {
39        self.city = Some(v.into());
40        self
41    }
42
43    pub fn province_code(mut self, v: impl Into<String>) -> Self {
44        self.province_code = Some(v.into());
45        self
46    }
47
48    pub fn country_code(mut self, v: CountryCode) -> Self {
49        self.country_code = Some(v);
50        self
51    }
52
53    pub fn postal_code(mut self, v: impl Into<String>) -> Self {
54        self.postal_code = Some(v.into());
55        self
56    }
57}