use serde::{Deserialize, Serialize};
use super::{
address::Address, currency::Currency, custom_tax_rate::CustomTaxRate, customer_id::CustomerId,
customer_type::CustomerType, invoicing_entity_id::InvoicingEntityId,
shipping_address::ShippingAddress,
};
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[non_exhaustive]
pub struct Customer {
#[serde(skip_serializing_if = "Option::is_none")]
pub alias: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub billing_address: Option<Address>,
#[serde(skip_serializing_if = "Option::is_none")]
pub billing_email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub buyer_reference: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub connected_account_id: Option<String>,
pub currency: Currency,
pub custom_properties: serde_json::Value,
pub custom_taxes: Vec<CustomTaxRate>,
#[serde(skip_serializing_if = "Option::is_none")]
pub customer_type: Option<CustomerType>,
#[serde(skip_serializing_if = "Option::is_none")]
pub first_name: Option<String>,
pub id: CustomerId,
pub invoicing_emails: Vec<String>,
pub invoicing_entity_id: InvoicingEntityId,
#[deprecated]
#[serde(skip_serializing_if = "Option::is_none")]
pub invoicing_language: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub legal_number: Option<String>,
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub phone: Option<String>,
pub preferred_locales: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub shipping_address: Option<ShippingAddress>,
#[serde(skip_serializing_if = "Option::is_none")]
pub vat_number: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
impl Customer {
#[must_use]
pub fn new(
currency: Currency,
custom_properties: serde_json::Value,
custom_taxes: Vec<CustomTaxRate>,
id: impl Into<CustomerId>,
invoicing_emails: Vec<String>,
invoicing_entity_id: impl Into<InvoicingEntityId>,
name: impl Into<String>,
preferred_locales: Vec<String>,
) -> Self {
#[allow(deprecated)]
Self {
alias: None,
billing_address: None,
billing_email: None,
buyer_reference: None,
connected_account_id: None,
currency,
custom_properties,
custom_taxes,
customer_type: None,
first_name: None,
id: id.into(),
invoicing_emails,
invoicing_entity_id: invoicing_entity_id.into(),
invoicing_language: None,
last_name: None,
legal_number: None,
name: name.into(),
phone: None,
preferred_locales,
shipping_address: None,
vat_number: None,
extra: serde_json::Map::new(),
}
}
}