quickbooks_types/models/
company_info.rs

1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5use super::common::{Addr, Email, MetaData, NtRef, PhoneNumber, WebAddr};
6#[cfg(feature = "builder")]
7use crate::error::QBTypeError;
8use crate::{QBFullUpdatable, QBSparseUpdateable};
9
10#[skip_serializing_none]
11#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
12#[serde(rename_all = "PascalCase", default)]
13#[cfg_attr(
14    feature = "builder",
15    derive(Builder),
16    builder(default, build_fn(error = "QBTypeError"), setter(into, strip_option))
17)]
18
19/// `CompanyInfo`
20///
21/// Represents the company profile and contact settings for a `QuickBooks` Online company.
22///
23/// Update semantics:
24/// - `QBFullUpdatable::can_full_update()` returns true when `sync_token`, `company_name`, and `company_addr` are present.
25///
26/// API reference:
27/// <https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/companyinfo>
28pub struct CompanyInfo {
29    /// The unique ID of the entity
30    pub id: Option<String>,
31    /// The unique sync token of the entity, used for concurrency control
32    pub sync_token: Option<String>,
33    /// Metadata about the entity
34    #[serde(skip_serializing)]
35    pub meta_data: Option<MetaData>,
36    /// Company address information
37    pub company_addr: Option<Addr>,
38    /// Name of the company
39    pub company_name: Option<String>,
40    /// Date the company was started in YYYY-MM-DD format
41    pub company_start_date: Option<NaiveDate>,
42    /// Country of the company
43    pub country: Option<String>,
44    /// Address used for customer communications
45    pub customer_communication_addr: Option<Addr>,
46    /// Domain of the company. Typically `QBO` for `QuickBooks` Online
47    pub domain: Option<String>,
48    /// Company email information
49    pub email: Option<Email>,
50    /// Month when the fiscal year starts
51    pub fiscal_year_start_month: Option<String>,
52    /// Legal address of the company
53    pub legal_addr: Option<Addr>,
54    /// Legal name of the company
55    pub legal_name: Option<String>,
56    /// Custom name-value pairs for the company
57    pub name_value: Option<Vec<NtRef>>,
58    /// Primary phone number for the company
59    pub primary_phone: Option<PhoneNumber>,
60    /// Indicates if the entity is a sparse object
61    pub sparse: Option<bool>,
62    /// Languages supported by the company
63    pub supported_languages: Option<String>,
64    /// Web address (website URL) of the company
65    pub web_addr: Option<WebAddr>,
66}
67
68impl QBFullUpdatable for CompanyInfo {
69    fn can_full_update(&self) -> bool {
70        self.sync_token.is_some() && self.company_name.is_some() && self.company_addr.is_some()
71    }
72}
73
74impl QBSparseUpdateable for CompanyInfo {
75    fn can_sparse_update(&self) -> bool {
76        self.can_full_update()
77    }
78}