djs_model/rest/application_identity_profile.rs
1//! Bodies and queries of the [application identity profile endpoints](https://docs.discord.com/developers/resources/application-identity-profile).
2
3use compact_str::CompactString;
4use serde::Serialize;
5
6use crate::application_identity_profile::ProfileData;
7
8/// The body of [Update Application Identity Profile](https://docs.discord.com/developers/resources/application-identity-profile#update-application-identity-profile).
9///
10/// Every field is optional. [`data`](Self::data) replaces the stored stats as a whole, so send
11/// all of them every time.
12///
13/// Contains floats, so it is `PartialEq` but not `Eq` (D-064).
14///
15/// discord.js counterpart: `RESTPatchAPIApplicationIdentityProfileJSONBody` (discord-api-types).
16///
17/// # Examples
18///
19/// ```
20/// use djs_model::rest::UpdateApplicationIdentityProfile;
21///
22/// let mut body = UpdateApplicationIdentityProfile::default();
23/// body.username = Some("ferris#1".into());
24/// assert_eq!(serde_json::to_string(&body)?, r#"{"username":"ferris#1"}"#);
25/// # Ok::<(), serde_json::Error>(())
26/// ```
27#[derive(Clone, Debug, Default, PartialEq, Serialize)]
28#[non_exhaustive]
29pub struct UpdateApplicationIdentityProfile {
30 /// The user's username in the app's system (up to 1024 characters).
31 #[serde(skip_serializing_if = "Option::is_none")]
32 pub username: Option<CompactString>,
33 /// The complete game stats (at most 10 KB serialized, up to 30 dynamic fields).
34 #[serde(skip_serializing_if = "Option::is_none")]
35 pub data: Option<ProfileData>,
36}
37
38/// The query of [Get Application Identities by External ID](https://docs.discord.com/developers/resources/application-identity-profile#get-application-identities-by-external-id).
39///
40/// discord.js counterpart: `RESTGetAPIApplicationIdentitiesQuery` (discord-api-types).
41#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
42#[non_exhaustive]
43pub struct GetApplicationIdentitiesByExternalId {
44 /// Disambiguates identities with the same provider type and external user ID.
45 pub provider_id: Option<CompactString>,
46}
47
48/// The optional body of [Delete Application Identity](https://docs.discord.com/developers/resources/application-identity-profile#delete-application-identity).
49///
50/// discord.js counterpart: `RESTPostAPIApplicationIdentityDeleteJSONBody` (discord-api-types).
51#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize)]
52#[non_exhaustive]
53pub struct DeleteApplicationIdentity {
54 /// Disambiguates identities with the same provider type and external user ID.
55 #[serde(skip_serializing_if = "Option::is_none")]
56 pub provider_id: Option<CompactString>,
57}