Skip to main content

io_msgraph/v1/rest/users/
contacts.rs

1//! Microsoft Graph contacts (`users.contacts`): list, delta, get,
2//! create, update, delete.
3//!
4//! <https://learn.microsoft.com/en-us/graph/api/resources/contact>
5
6use alloc::{string::String, vec::Vec};
7
8use serde::{Deserialize, Serialize};
9
10use crate::v1::{field::MsgraphField, rest::users::messages::MsgraphEmailAddress};
11
12pub mod create;
13pub mod delete;
14pub mod delta;
15pub mod get;
16pub mod list;
17pub mod update;
18#[cfg(feature = "vcard")]
19pub mod vcard;
20
21/// A contact in a contact folder. Doubles as the create/update body.
22///
23/// Unset fields are left out (an update preserves them), null fields
24/// are serialized as explicit nulls (an update clears them), and a set
25/// empty collection clears the collection.
26#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
27#[serde(rename_all = "camelCase")]
28pub struct MsgraphContact {
29    /// The unique identifier of the contact.
30    #[serde(default, skip_serializing_if = "String::is_empty")]
31    pub id: String,
32    /// The display name of the contact.
33    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
34    pub display_name: MsgraphField<String>,
35    /// The given name of the contact.
36    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
37    pub given_name: MsgraphField<String>,
38    /// The middle name of the contact.
39    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
40    pub middle_name: MsgraphField<String>,
41    /// The family name of the contact.
42    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
43    pub surname: MsgraphField<String>,
44    /// The nickname of the contact.
45    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
46    pub nick_name: MsgraphField<String>,
47    /// The title of the contact.
48    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
49    pub title: MsgraphField<String>,
50    /// How the contact is filed under in the folder listing.
51    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
52    pub file_as: MsgraphField<String>,
53    /// The email addresses of the contact.
54    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
55    pub email_addresses: MsgraphField<Vec<MsgraphEmailAddress>>,
56    /// The instant messaging addresses of the contact.
57    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
58    pub im_addresses: MsgraphField<Vec<String>>,
59    /// The business phone numbers of the contact.
60    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
61    pub business_phones: MsgraphField<Vec<String>>,
62    /// The home phone numbers of the contact.
63    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
64    pub home_phones: MsgraphField<Vec<String>>,
65    /// The mobile phone number of the contact.
66    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
67    pub mobile_phone: MsgraphField<String>,
68    /// The home address of the contact.
69    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
70    pub home_address: MsgraphField<MsgraphPhysicalAddress>,
71    /// The business address of the contact.
72    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
73    pub business_address: MsgraphField<MsgraphPhysicalAddress>,
74    /// The alternative address of the contact.
75    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
76    pub other_address: MsgraphField<MsgraphPhysicalAddress>,
77    /// The job title of the contact.
78    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
79    pub job_title: MsgraphField<String>,
80    /// The name of the contact's company.
81    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
82    pub company_name: MsgraphField<String>,
83    /// The department the contact works in.
84    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
85    pub department: MsgraphField<String>,
86    /// The office location of the contact.
87    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
88    pub office_location: MsgraphField<String>,
89    /// The profession of the contact.
90    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
91    pub profession: MsgraphField<String>,
92    /// The name of the contact's assistant.
93    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
94    pub assistant_name: MsgraphField<String>,
95    /// The name of the contact's manager.
96    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
97    pub manager: MsgraphField<String>,
98    /// The business home page of the contact.
99    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
100    pub business_home_page: MsgraphField<String>,
101    /// Birthday as an ISO 8601 date-time (e.g. `1983-04-01T00:00:00Z`).
102    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
103    pub birthday: MsgraphField<String>,
104    /// The name of the contact's spouse or partner.
105    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
106    pub spouse_name: MsgraphField<String>,
107    /// The names of the contact's children.
108    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
109    pub children: MsgraphField<Vec<String>>,
110    /// The free-form notes about the contact.
111    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
112    pub personal_notes: MsgraphField<String>,
113    /// The categories associated with the contact.
114    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
115    pub categories: MsgraphField<Vec<String>>,
116    /// The identifier of the containing contact folder.
117    #[serde(default, skip_serializing_if = "Option::is_none")]
118    pub parent_folder_id: Option<String>,
119    /// The creation date, as an ISO 8601 date-time.
120    #[serde(default, skip_serializing_if = "Option::is_none")]
121    pub created_date_time: Option<String>,
122    /// The last modification date, as an ISO 8601 date-time.
123    #[serde(default, skip_serializing_if = "Option::is_none")]
124    pub last_modified_date_time: Option<String>,
125    /// The version marker of the contact, changing on every update.
126    #[serde(default, skip_serializing_if = "Option::is_none")]
127    pub change_key: Option<String>,
128    /// Single-value extended MAPI properties attached to the contact.
129    ///
130    /// They ride inline in create and update bodies, but responses
131    /// only carry them when the request `$expand`ed them by id.
132    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
133    pub single_value_extended_properties: MsgraphField<Vec<MsgraphSingleValueExtendedProperty>>,
134}
135
136/// A physical address of a contact (home, business or other).
137///
138/// The whole object is replaced at once, so its components stay plain
139/// options.
140#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
141#[serde(rename_all = "camelCase")]
142pub struct MsgraphPhysicalAddress {
143    /// The street name and number.
144    #[serde(default, skip_serializing_if = "Option::is_none")]
145    pub street: Option<String>,
146    /// The city.
147    #[serde(default, skip_serializing_if = "Option::is_none")]
148    pub city: Option<String>,
149    /// The state or province.
150    #[serde(default, skip_serializing_if = "Option::is_none")]
151    pub state: Option<String>,
152    /// The country or region.
153    #[serde(default, skip_serializing_if = "Option::is_none")]
154    pub country_or_region: Option<String>,
155    /// The postal code.
156    #[serde(default, skip_serializing_if = "Option::is_none")]
157    pub postal_code: Option<String>,
158}
159
160/// A single-value extended MAPI property: the full property id (the
161/// `String {guid} Name <name>` form) and its value.
162///
163/// <https://learn.microsoft.com/en-us/graph/api/resources/singlevaluelegacyextendedproperty>
164#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
165#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
166#[serde(rename_all = "camelCase")]
167pub struct MsgraphSingleValueExtendedProperty {
168    /// The full property identifier.
169    #[serde(default)]
170    pub id: String,
171    /// The value of the property.
172    #[serde(default)]
173    pub value: String,
174}