use serde::{Deserialize, Serialize};
use super::{
address::Address, currency::Currency, custom_tax_rate::CustomTaxRate,
customer_type::CustomerType, invoicing_entity_id::InvoicingEntityId,
shipping_address::ShippingAddress,
};
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct CustomerUpdateRequest {
#[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>,
pub currency: Currency,
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_properties: Option<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 exemption_reason: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub first_name: Option<String>,
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 is_tax_exempt: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub legal_number: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub phone: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_locales: Option<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 CustomerUpdateRequest {
#[must_use]
pub fn new(
currency: Currency,
custom_taxes: Vec<CustomTaxRate>,
invoicing_emails: Vec<String>,
invoicing_entity_id: impl Into<InvoicingEntityId>,
) -> Self {
#[allow(deprecated)]
Self {
alias: None,
billing_address: None,
billing_email: None,
buyer_reference: None,
currency,
custom_properties: None,
custom_taxes,
customer_type: None,
exemption_reason: None,
first_name: None,
invoicing_emails,
invoicing_entity_id: invoicing_entity_id.into(),
invoicing_language: None,
is_tax_exempt: None,
last_name: None,
legal_number: None,
name: None,
phone: None,
preferred_locales: None,
shipping_address: None,
vat_number: None,
extra: serde_json::Map::new(),
}
}
#[must_use]
pub fn alias(mut self, alias: impl Into<String>) -> Self {
self.alias = Some(alias.into());
self
}
#[must_use]
pub fn billing_address(mut self, billing_address: impl Into<Address>) -> Self {
self.billing_address = Some(billing_address.into());
self
}
#[must_use]
pub fn billing_email(mut self, billing_email: impl Into<String>) -> Self {
self.billing_email = Some(billing_email.into());
self
}
#[must_use]
pub fn buyer_reference(mut self, buyer_reference: impl Into<String>) -> Self {
self.buyer_reference = Some(buyer_reference.into());
self
}
#[must_use]
pub fn custom_properties(mut self, custom_properties: impl Into<serde_json::Value>) -> Self {
self.custom_properties = Some(custom_properties.into());
self
}
#[must_use]
pub fn customer_type(mut self, customer_type: impl Into<CustomerType>) -> Self {
self.customer_type = Some(customer_type.into());
self
}
#[must_use]
pub fn exemption_reason(mut self, exemption_reason: impl Into<String>) -> Self {
self.exemption_reason = Some(exemption_reason.into());
self
}
#[must_use]
pub fn first_name(mut self, first_name: impl Into<String>) -> Self {
self.first_name = Some(first_name.into());
self
}
#[must_use]
#[deprecated]
#[allow(deprecated)]
pub fn invoicing_language(mut self, invoicing_language: impl Into<String>) -> Self {
self.invoicing_language = Some(invoicing_language.into());
self
}
#[must_use]
pub fn is_tax_exempt(mut self, is_tax_exempt: impl Into<bool>) -> Self {
self.is_tax_exempt = Some(is_tax_exempt.into());
self
}
#[must_use]
pub fn last_name(mut self, last_name: impl Into<String>) -> Self {
self.last_name = Some(last_name.into());
self
}
#[must_use]
pub fn legal_number(mut self, legal_number: impl Into<String>) -> Self {
self.legal_number = Some(legal_number.into());
self
}
#[must_use]
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
#[must_use]
pub fn phone(mut self, phone: impl Into<String>) -> Self {
self.phone = Some(phone.into());
self
}
#[must_use]
pub fn preferred_locales(mut self, preferred_locales: impl Into<Vec<String>>) -> Self {
self.preferred_locales = Some(preferred_locales.into());
self
}
#[must_use]
pub fn shipping_address(mut self, shipping_address: impl Into<ShippingAddress>) -> Self {
self.shipping_address = Some(shipping_address.into());
self
}
#[must_use]
pub fn vat_number(mut self, vat_number: impl Into<String>) -> Self {
self.vat_number = Some(vat_number.into());
self
}
}