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/// API reference:
24/// <https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/companyinfo>
25pub struct CompanyInfo {
26    /// The unique ID of the entity
27    pub id: Option<String>,
28    /// The unique sync token of the entity, used for concurrency control
29    pub sync_token: Option<String>,
30    /// Metadata about the entity
31    #[serde(skip_serializing)]
32    pub meta_data: Option<MetaData>,
33    /// Company address information
34    pub company_addr: Option<Addr>,
35    /// Name of the company
36    pub company_name: Option<String>,
37    /// Date the company was started in YYYY-MM-DD format
38    pub company_start_date: Option<NaiveDate>,
39    /// Country of the company
40    pub country: Option<String>,
41    /// Address used for customer communications
42    pub customer_communication_addr: Option<Addr>,
43    /// Domain of the company. Typically `QBO` for `QuickBooks` Online
44    pub domain: Option<String>,
45    /// Company email information
46    pub email: Option<Email>,
47    /// Month when the fiscal year starts
48    pub fiscal_year_start_month: Option<String>,
49    /// Legal address of the company
50    pub legal_addr: Option<Addr>,
51    /// Legal name of the company
52    pub legal_name: Option<String>,
53    /// Custom name-value pairs for the company
54    pub name_value: Option<Vec<NtRef>>,
55    /// Primary phone number for the company
56    pub primary_phone: Option<PhoneNumber>,
57    /// Indicates if the entity is a sparse object
58    pub sparse: Option<bool>,
59    /// Languages supported by the company
60    pub supported_languages: Option<String>,
61    /// Web address (website URL) of the company
62    pub web_addr: Option<WebAddr>,
63}
64
65impl QBFullUpdatable for CompanyInfo {
66    fn can_full_update(&self) -> bool {
67        self.sync_token.is_some() && self.company_name.is_some() && self.company_addr.is_some()
68    }
69}
70
71impl QBSparseUpdateable for CompanyInfo {
72    fn can_sparse_update(&self) -> bool {
73        self.can_full_update() && self.sparse.is_some_and(|x| x)
74    }
75}