wave-api 0.1.0

Typed Rust client for the Wave Accounting GraphQL API
Documentation
use serde::Serialize;

use crate::enums::CountryCode;

/// Input for an address on mutations.
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AddressInput {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub address_line1: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub address_line2: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub city: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub province_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub country_code: Option<CountryCode>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub postal_code: Option<String>,
}

impl AddressInput {
    pub fn new() -> Self {
        Self::default()
    }

    pub fn address_line1(mut self, v: impl Into<String>) -> Self {
        self.address_line1 = Some(v.into());
        self
    }

    pub fn address_line2(mut self, v: impl Into<String>) -> Self {
        self.address_line2 = Some(v.into());
        self
    }

    pub fn city(mut self, v: impl Into<String>) -> Self {
        self.city = Some(v.into());
        self
    }

    pub fn province_code(mut self, v: impl Into<String>) -> Self {
        self.province_code = Some(v.into());
        self
    }

    pub fn country_code(mut self, v: CountryCode) -> Self {
        self.country_code = Some(v);
        self
    }

    pub fn postal_code(mut self, v: impl Into<String>) -> Self {
        self.postal_code = Some(v.into());
        self
    }
}